From 0fcdaf017c334f71c608b00e2cae2fce3d5a5d88 Mon Sep 17 00:00:00 2001 From: DanB Date: Mon, 16 Jan 2017 16:39:31 +0100 Subject: [PATCH] Storage.mongo - fix GetLCR --- engine/onstor_it_test.go | 11 ++++------- engine/storage_mongo_datadb.go | 5 +++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/engine/onstor_it_test.go b/engine/onstor_it_test.go index 636b14ce2..d83187d97 100644 --- a/engine/onstor_it_test.go +++ b/engine/onstor_it_test.go @@ -965,8 +965,8 @@ func testOnStorITCRUDLCR(t *testing.T) { Tenant: "cgrates.org", Category: "call", Direction: "*out", - Account: "*any", - Subject: "*any", + Account: "testOnStorITCRUDLCR", + Subject: "testOnStorITCRUDLCR", Activations: []*LCRActivation{ &LCRActivation{ ActivationTime: time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC).Local(), @@ -989,21 +989,18 @@ func testOnStorITCRUDLCR(t *testing.T) { }, }, } - /*FixMe @Edwardo22 + if _, rcvErr := onStor.GetLCR(lcr.GetId(), true, utils.NonTransactional); rcvErr != utils.ErrNotFound { t.Error(rcvErr) } - */ if err := onStor.SetLCR(lcr, utils.NonTransactional); err != nil { t.Error(err) } - /*FixMe @Edwardo22 if rcv, err := onStor.GetLCR(lcr.GetId(), true, utils.NonTransactional); err != nil { t.Error(err) } else if !reflect.DeepEqual(lcr, rcv) { - t.Errorf("Expecting: %v, received: %v", lcr, rcv) //rcv nil + t.Errorf("Expecting: %v, received: %v", lcr, rcv) } - */ } func testOnStorITCRUDCdrStats(t *testing.T) { diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index b2e381da3..3e64575f8 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -791,12 +791,13 @@ func (ms *MongoStorage) GetLCR(key string, skipCache bool, transactionID string) cCommit := cacheCommit(transactionID) if err = col.Find(bson.M{"key": key}).One(&result); err != nil { if err == mgo.ErrNotFound { - cache.Set(cacheKey, nil, cacheCommit(transactionID), transactionID) + cache.Set(cacheKey, nil, cCommit, transactionID) err = utils.ErrNotFound } return nil, err } - cache.Set(cacheKey, result.Value, cCommit, transactionID) + lcr = result.Value + cache.Set(cacheKey, lcr, cCommit, transactionID) return }