Storage.mongo - fix GetLCR

This commit is contained in:
DanB
2017-01-16 16:39:31 +01:00
parent 0fbdc6fa42
commit 0fcdaf017c
2 changed files with 7 additions and 9 deletions

View File

@@ -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) {

View File

@@ -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
}