From f2214052b64f2b8307252fd20c8ebad0f9148e9a Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Fri, 14 Jul 2023 11:01:07 -0400 Subject: [PATCH] Solve struct literal uses unkeyed fields warning --- apier/v1/suppliers_it_test.go | 2 +- apier/v1/thresholds_it_test.go | 2 +- migrator/storage_mongo_stordb.go | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apier/v1/suppliers_it_test.go b/apier/v1/suppliers_it_test.go index 4ca445aba..16ead9053 100644 --- a/apier/v1/suppliers_it_test.go +++ b/apier/v1/suppliers_it_test.go @@ -866,7 +866,7 @@ func testV1SplSGetSupplierProfileIDs(t *testing.T) { "SPL_ACNT_1001", "SPL_LEASTCOST_1", "SPL_WEIGHT_2", "SPL_WEIGHT_1", "SPL_QOS_3", "TEST_PROFILE1", "SPL_LCR"} var result []string if err := splSv1Rpc.Call(utils.APIerSv1GetSupplierProfileIDs, - &utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{"cgrates.org"}}, &result); err != nil { + &utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{Tenant: "cgrates.org"}}, &result); err != nil { t.Error(err) } else if len(expected) != len(result) { t.Errorf("Expecting : %+v, received: %+v", expected, result) diff --git a/apier/v1/thresholds_it_test.go b/apier/v1/thresholds_it_test.go index 96680176f..33ce5a7de 100644 --- a/apier/v1/thresholds_it_test.go +++ b/apier/v1/thresholds_it_test.go @@ -381,7 +381,7 @@ func testV1TSGetThresholdsAfterRestart(t *testing.T) { func testv1TSGetThresholdProfileIDs(t *testing.T) { expected := []string{"THD_STATS_1", "THD_STATS_2", "THD_STATS_3", "THD_RES_1", "THD_CDRS_1", "THD_ACNT_BALANCE_1", "THD_ACNT_EXPIRED"} var result []string - if err := tSv1Rpc.Call(utils.APIerSv1GetThresholdProfileIDs, utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{"cgrates.org"}}, &result); err != nil { + if err := tSv1Rpc.Call(utils.APIerSv1GetThresholdProfileIDs, utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{Tenant: "cgrates.org"}}, &result); err != nil { t.Error(err) } else if len(expected) != len(result) { t.Errorf("Expecting : %+v, received: %+v", expected, result) diff --git a/migrator/storage_mongo_stordb.go b/migrator/storage_mongo_stordb.go index ea3692b05..b79e334a1 100644 --- a/migrator/storage_mongo_stordb.go +++ b/migrator/storage_mongo_stordb.go @@ -81,14 +81,23 @@ func (v1ms *mongoStorDBMigrator) renameV1SMCosts() (err error) { return err } return v1ms.mgoDB.DB().RunCommand(v1ms.mgoDB.GetContext(), - bson.D{{"create", utils.SessionCostsTBL}}).Err() + bson.D{{Key: "create", Value: utils.SessionCostsTBL}}).Err() } -func (v1ms *mongoStorDBMigrator) createV1SMCosts() (err error) { - v1ms.mgoDB.DB().Collection(utils.OldSMCosts).Drop(v1ms.mgoDB.GetContext()) - v1ms.mgoDB.DB().Collection(utils.SessionCostsTBL).Drop(v1ms.mgoDB.GetContext()) +func (v1ms *mongoStorDBMigrator) createV1SMCosts() error { + err := v1ms.mgoDB.DB().Collection(utils.OldSMCosts).Drop(v1ms.mgoDB.GetContext()) + if err != nil { + return err + } + err = v1ms.mgoDB.DB().Collection(utils.SessionCostsTBL).Drop(v1ms.mgoDB.GetContext()) + if err != nil { + return err + } return v1ms.mgoDB.DB().RunCommand(v1ms.mgoDB.GetContext(), - bson.D{{"create", utils.OldSMCosts}, {"size", 1024}, {"capped", true}}).Err() + bson.D{ + {Key: "create", Value: utils.OldSMCosts}, + {Key: "size", Value: 1024}, + {Key: "capped", Value: true}}).Err() } // get