From 6690f72f00f61d9132af9615832a2e4326935cbc Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 6 Dec 2018 14:19:53 +0200 Subject: [PATCH] Fixed GetAccount --- engine/storage_mongo_datadb_new.go | 1 + engine/storage_mongo_stordb_new.go | 8 +++++--- general_tests/accounts_it_test.go | 7 +------ general_tests/cdre_it_test.go | 10 +++------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/engine/storage_mongo_datadb_new.go b/engine/storage_mongo_datadb_new.go index 7a4e04636..80fe67e1f 100644 --- a/engine/storage_mongo_datadb_new.go +++ b/engine/storage_mongo_datadb_new.go @@ -995,6 +995,7 @@ func (ms *MongoStorage) GetAccount(key string) (result *Account, err error) { cur := ms.getCol(colAcc).FindOne(sctx, bson.M{"id": key}) if err := cur.Decode(result); err != nil { if err == mongo.ErrNoDocuments { + result = nil return utils.ErrNotFound } return err diff --git a/engine/storage_mongo_stordb_new.go b/engine/storage_mongo_stordb_new.go index 7d931d817..5e9d15232 100644 --- a/engine/storage_mongo_stordb_new.go +++ b/engine/storage_mongo_stordb_new.go @@ -1322,11 +1322,13 @@ func (ms *MongoStorage) GetCDRs(qryFltr *utils.CDRsFilter, remove bool) ([]*CDR, } if qryFltr.Count { var cnt int64 - err := ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) { + if err := ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) { cnt, err = ms.getCol(ColCDRs).Count(sctx, filters, cop) return err - }) - return nil, cnt, err + }); err != nil { + return nil, 0, err + } + return nil, cnt, nil } // Execute query var cdrs []*CDR diff --git a/general_tests/accounts_it_test.go b/general_tests/accounts_it_test.go index 7bc4c602b..5d9f35513 100644 --- a/general_tests/accounts_it_test.go +++ b/general_tests/accounts_it_test.go @@ -81,12 +81,7 @@ func testV1AccLoadConfig(t *testing.T) { if accCfg, err = config.NewCGRConfigFromFolder(accCfgPath); err != nil { t.Error(err) } - switch accConfDIR { - case "tutmongo": // Mongo needs more time to reset db, need to investigate - accDelay = 2000 - default: - accDelay = 1000 - } + accDelay = 1000 } func testV1AccInitDataDb(t *testing.T) { diff --git a/general_tests/cdre_it_test.go b/general_tests/cdre_it_test.go index da1ee67ab..413dccd30 100644 --- a/general_tests/cdre_it_test.go +++ b/general_tests/cdre_it_test.go @@ -23,6 +23,7 @@ package general_tests import ( "net/rpc" "net/rpc/jsonrpc" + //"os" "path" "testing" @@ -79,12 +80,7 @@ func testCDREInitCfg(t *testing.T) { } cdreCfg.DataFolderPath = cdreDataDir config.SetCgrConfig(cdreCfg) - switch cdreConfigDIR { - case "tutmongo": - cdreDelay = 2000 - default: - cdreDelay = 1000 - } + cdreDelay = 1000 } func testCDREInitDataDb(t *testing.T) { @@ -173,7 +169,7 @@ func testCDREExport(t *testing.T) { } func testCDREStopEngine(t *testing.T) { - if err := engine.KillEngine(100); err != nil { + if err := engine.KillEngine(cdreDelay); err != nil { t.Error(err) } }