Replaced hardcoded strings with consts in RPC.Call methods

This commit is contained in:
adragusin
2019-11-22 15:34:41 +02:00
committed by Dan Christian Bogos
parent 413e47ff37
commit d1787cb3fa
65 changed files with 444 additions and 324 deletions

View File

@@ -333,7 +333,7 @@ func testA1itConcurrentAPs(t *testing.T) {
ActionPlanIDs: &[]string{"PACKAGE_1"},
}
var reply string
if err := a1rpc.Call("ApierV2.SetAccount", attrSetAcnt, &reply); err != nil {
if err := a1rpc.Call(utils.ApierV2SetAccount, attrSetAcnt, &reply); err != nil {
t.Error(err)
}
wg.Done()
@@ -362,7 +362,7 @@ func testA1itConcurrentAPs(t *testing.T) {
}(acnt)
go func(acnt string) {
var reply string
if err := a1rpc.Call("ApierV1.RemoveActionTiming",
if err := a1rpc.Call(utils.ApierV1RemoveActionTiming,
v1.AttrRemoveActionTiming{Tenant: "cgrates.org", Account: acnt, ActionPlanId: "PACKAGE_1"}, &reply); err != nil {
t.Error(err)
}
@@ -375,7 +375,7 @@ func testA1itConcurrentAPs(t *testing.T) {
ActionPlanIDs: &[]string{"PACKAGE_2"},
}
var reply string
if err := a1rpc.Call("ApierV2.SetAccount", attrSetAcnt, &reply); err != nil {
if err := a1rpc.Call(utils.ApierV2SetAccount, attrSetAcnt, &reply); err != nil {
t.Error(err)
}
wg.Done()

View File

@@ -143,7 +143,7 @@ func testV1AccGetAccountAfterLoad(t *testing.T) {
func testV1AccRemAccount(t *testing.T) {
var reply string
if err := accRpc.Call("ApierV1.RemoveAccount",
if err := accRpc.Call(utils.ApierV1RemoveAccount,
&utils.AttrRemoveAccount{Tenant: "cgrates.org", Account: "1001"},
&reply); err != nil {
t.Error(err)
@@ -163,7 +163,7 @@ func testV1AccGetAccountAfterDelete(t *testing.T) {
func testV1AccSetAccount(t *testing.T) {
var reply string
if err := accRpc.Call("ApierV2.SetAccount",
if err := accRpc.Call(utils.ApierV2SetAccount,
&utils.AttrSetAccount{Tenant: "cgrates.org", Account: "testacc"}, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
@@ -181,7 +181,7 @@ func testV1AccGetAccountAfterSet(t *testing.T) {
func testV1AccRemAccountSet(t *testing.T) {
var reply string
if err := accRpc.Call("ApierV1.RemoveAccount",
if err := accRpc.Call(utils.ApierV1RemoveAccount,
&utils.AttrRemoveAccount{Tenant: "cgrates.org", Account: "testacc"},
&reply); err != nil {
t.Error(err)
@@ -203,7 +203,7 @@ func testV1AccGetAccountSetAfterDelete(t *testing.T) {
Need to investigate for redis why didn't return not found
func testV1AccRemAccountAfterDelete(t *testing.T) {
var reply string
if err := accRpc.Call("ApierV1.RemoveAccount",
if err := accRpc.Call(utils.ApierV1RemoveAccount,
&utils.AttrRemoveAccount{Tenant: "cgrates.org", Account: "testacc"},
&reply); err == nil || err.Error() != utils.NewErrServerError(utils.ErrNotFound).Error() {
t.Error(err)
@@ -240,7 +240,7 @@ func testV1AccSendToThreshold(t *testing.T) {
{Identifier: utils.DISABLE_ACCOUNT},
{Identifier: utils.LOG},
}}
if err := accRpc.Call("ApierV2.SetActions", attrsAA, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
if err := accRpc.Call(utils.ApierV2SetActions, attrsAA, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
t.Error("Got error on ApierV2.SetActions: ", err.Error())
} else if reply != utils.OK {
t.Errorf("Calling ApierV2.SetActions received: %s", reply)

View File

@@ -138,14 +138,14 @@ func testV2CDRsLoadTariffPlanFromFolder(t *testing.T) {
}
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
var resp string
if err := cdrsRpc.Call("ApierV1.RemoveChargerProfile",
if err := cdrsRpc.Call(utils.ApierV1RemoveChargerProfile,
&utils.TenantID{Tenant: "cgrates.org", ID: "SupplierCharges"}, &resp); err != nil {
t.Error(err)
} else if resp != utils.OK {
t.Error("Unexpected reply returned", resp)
}
var reply *engine.AttributeProfile
if err := cdrsRpc.Call("ApierV1.GetChargerProfile",
if err := cdrsRpc.Call(utils.ApierV1GetChargerProfile,
&utils.TenantID{Tenant: "cgrates.org", ID: "SupplierCharges"},
&reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
@@ -185,7 +185,7 @@ func testV2CDRsProcessCDR(t *testing.T) {
func testV2CDRsGetCdrs(t *testing.T) {
var cdrCnt int64
req := utils.AttrGetCdrs{}
if err := cdrsRpc.Call("ApierV2.CountCDRs", req, &cdrCnt); err != nil {
if err := cdrsRpc.Call(utils.ApierV2CountCDRs, req, &cdrCnt); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if cdrCnt != 2 {
t.Error("Unexpected number of CDRs returned: ", cdrCnt)
@@ -256,7 +256,7 @@ func testV2CDRsProcessCDR2(t *testing.T) {
func testV2CDRsGetCdrs2(t *testing.T) {
var cdrCnt int64
req := utils.AttrGetCdrs{Accounts: []string{"testV2CDRsProcessCDR2"}}
if err := cdrsRpc.Call("ApierV2.CountCDRs", req, &cdrCnt); err != nil {
if err := cdrsRpc.Call(utils.ApierV2CountCDRs, req, &cdrCnt); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if cdrCnt != 2 {
t.Error("Unexpected number of CDRs returned: ", cdrCnt)
@@ -330,7 +330,7 @@ func testV2CDRsProcessCDR3(t *testing.T) {
func testV2CDRsGetCdrs3(t *testing.T) {
var cdrCnt int64
req := utils.AttrGetCdrs{Accounts: []string{"testV2CDRsProcessCDR3"}}
if err := cdrsRpc.Call("ApierV2.CountCDRs", req, &cdrCnt); err != nil {
if err := cdrsRpc.Call(utils.ApierV2CountCDRs, req, &cdrCnt); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if cdrCnt != 1 {
t.Error("Unexpected number of CDRs returned: ", cdrCnt)
@@ -503,7 +503,7 @@ func testV2CDRsSetThresholdProfile(t *testing.T) {
// Set Action
attrsAA := &utils.AttrSetActions{ActionsId: "ACT_THD_PoccessCDR", Actions: []*utils.TPAction{{Identifier: utils.LOG}}}
if err := cdrsRpc.Call("ApierV2.SetActions", attrsAA, &actreply); err != nil && err.Error() != utils.ErrExists.Error() {
if err := cdrsRpc.Call(utils.ApierV2SetActions, attrsAA, &actreply); err != nil && err.Error() != utils.ErrExists.Error() {
t.Error("Got error on ApierV2.SetActions: ", err.Error())
} else if actreply != utils.OK {
t.Errorf("Calling ApierV2.SetActions received: %s", actreply)
@@ -600,7 +600,7 @@ func testV2CDRsGetStats1(t *testing.T) {
func testV2CDRsGetThreshold1(t *testing.T) {
expected := []string{"THD_ACNT_1001", "THD_PoccessCDR"}
var result []string
if err := cdrsRpc.Call("ApierV1.GetThresholdProfileIDs",
if err := cdrsRpc.Call(utils.ApierV1GetThresholdProfileIDs,
utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{"cgrates.org"}}, &result); err != nil {
t.Error(err)
} else if len(expected) != len(result) {

View File

@@ -597,7 +597,7 @@ func testCdrsHttpCdrReplication2(t *testing.T) {
}
var reply string
for _, cdr := range cdrs {
if err := cdrsMasterRpc.Call("CdrsV2.ProcessCdr", cdr, &reply); err != nil {
if err := cdrsMasterRpc.Call(utils.CdrsV2ProcessCdr, cdr, &reply); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if reply != utils.OK {
t.Error("Unexpected reply received: ", reply)

View File

@@ -164,7 +164,7 @@ func testV1DataDataDebitUsageWith10Kilo(t *testing.T) {
AnswerTime: time.Date(2013, 11, 7, 7, 42, 20, 0, time.UTC).String(),
}
tStart := time.Now()
if err := dataRpc.Call("ApierV1.DebitUsage",
if err := dataRpc.Call(utils.ApierV1DebitUsage,
engine.UsageRecordWithArgDispatcher{UsageRecord: usageRecord}, &reply); err != nil {
t.Error(err)
}
@@ -190,7 +190,7 @@ func testV1DataGetCostWith10Kilo(t *testing.T) {
Subject: "10kilo", AnswerTime: "*now", Usage: 256000000}
var rply *engine.DataCost
tStart := time.Now()
if err := dataRpc.Call("ApierV1.GetDataCost", attrs, &rply); err != nil {
if err := dataRpc.Call(utils.ApierV1GetDataCost, attrs, &rply); err != nil {
t.Error("Unexpected nil error received: ", err.Error())
} else if rply.Cost != 25600.000000 {
t.Errorf("Unexpected cost received: %f", rply.Cost)
@@ -298,7 +298,7 @@ func testV1DataDataDebitUsage1G0(t *testing.T) {
AnswerTime: time.Date(2013, 11, 7, 7, 42, 20, 0, time.UTC).String(),
}
tStart := time.Now()
if err := dataRpc.Call("ApierV1.DebitUsage",
if err := dataRpc.Call(utils.ApierV1DebitUsage,
engine.UsageRecordWithArgDispatcher{UsageRecord: usageRecord}, &reply); err != nil {
t.Error(err)
}
@@ -324,7 +324,7 @@ func testV1DataGetCost1G0(t *testing.T) {
Subject: "10kilo", AnswerTime: "*now", Usage: 1000000000}
var rply *engine.DataCost
tStart := time.Now()
if err := dataRpc.Call("ApierV1.GetDataCost", attrs, &rply); err != nil {
if err := dataRpc.Call(utils.ApierV1GetDataCost, attrs, &rply); err != nil {
t.Error("Unexpected nil error received: ", err.Error())
} else if rply.Cost != 100000.000000 {
t.Errorf("Unexpected cost received: %f", rply.Cost)

View File

@@ -120,14 +120,14 @@ func testDestManagLoadTariffPlanFromFolderAll(t *testing.T) {
func testDestManagAllDestinationLoaded(t *testing.T) {
dests := make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 6 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
}
var rcvStats utils.CacheStats
if err := destRPC.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
if err := destRPC.Call(utils.ApierV1GetCacheStats, utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if rcvStats.Destinations != 9 {
t.Errorf("Calling ApierV1.GetCacheStats received: %+v", rcvStats)
@@ -146,14 +146,14 @@ func testDestManagLoadTariffPlanFromFolderRemoveSome(t *testing.T) {
func testDestManagRemoveSomeDestinationLoaded(t *testing.T) {
dests := make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 6 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
}
var rcvStats utils.CacheStats
if err := destRPC.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
if err := destRPC.Call(utils.ApierV1GetCacheStats, utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if rcvStats.Destinations != 9 {
t.Errorf("Calling ApierV1.GetCacheStats received: %+v", rcvStats)
@@ -171,14 +171,14 @@ func testDestManagLoadTariffPlanFromFolderRemoveSomeFlush(t *testing.T) {
func testDestManagRemoveSomeFlushDestinationLoaded(t *testing.T) {
dests := make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 4 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
}
var rcvStats utils.CacheStats
if err := destRPC.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
if err := destRPC.Call(utils.ApierV1GetCacheStats, utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if rcvStats.Destinations != 5 {
t.Errorf("Calling ApierV1.GetCacheStats received: %+v", rcvStats)
@@ -196,14 +196,14 @@ func testDestManagLoadTariffPlanFromFolderAddBack(t *testing.T) {
func testDestManagAddBackDestinationLoaded(t *testing.T) {
dests := make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 6 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
}
var rcvStats utils.CacheStats
if err := destRPC.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
if err := destRPC.Call(utils.ApierV1GetCacheStats, utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if rcvStats.Destinations != 9 {
t.Errorf("Calling ApierV1.GetCacheStats received: %+v", rcvStats)
@@ -221,14 +221,14 @@ func testDestManagLoadTariffPlanFromFolderAddOne(t *testing.T) {
func testDestManagAddOneDestinationLoaded(t *testing.T) {
dests := make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 7 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
}
var rcvStats utils.CacheStats
if err := destRPC.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
if err := destRPC.Call(utils.ApierV1GetCacheStats, utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if rcvStats.Destinations != 10 {
t.Errorf("Calling ApierV1.GetCacheStats received: %+v", rcvStats)
@@ -240,7 +240,7 @@ func testDestManagCacheWithGetCache(t *testing.T) {
t.Fatal(err)
}
var reply string
if err := destRPC.Call("ApierV1.ReloadCache", utils.AttrReloadCache{}, &reply); err != nil {
if err := destRPC.Call(utils.ApierV1ReloadCache, utils.AttrReloadCache{}, &reply); err != nil {
t.Error("Got error on ApierV1.ReloadCache: ", err.Error())
} else if reply != utils.OK {
t.Errorf("Calling ApierV1.ReloadCache received: %+v", reply)
@@ -253,14 +253,14 @@ func testDestManagCacheWithGetCache(t *testing.T) {
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
dests := make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 1 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
}
var rcvStats utils.CacheStats
if err := destRPC.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
if err := destRPC.Call(utils.ApierV1GetCacheStats, utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if rcvStats.Destinations != 2 {
t.Errorf("Calling ApierV1.GetCacheStats received: %+v", rcvStats)
@@ -273,13 +273,13 @@ func testDestManagCacheWithGetCache(t *testing.T) {
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
dests = make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 1 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
}
if err := destRPC.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
if err := destRPC.Call(utils.ApierV1GetCacheStats, utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if rcvStats.Destinations != 1 {
t.Errorf("Calling ApierV1.GetCacheStats received: %+v", rcvStats)
@@ -291,7 +291,7 @@ func testDestManagCacheWithGetCost(t *testing.T) {
t.Fatal(err)
}
var reply string
if err := destRPC.Call("ApierV1.ReloadCache", utils.AttrReloadCache{}, &reply); err != nil {
if err := destRPC.Call(utils.ApierV1ReloadCache, utils.AttrReloadCache{}, &reply); err != nil {
t.Error("Got error on ApierV1.ReloadCache: ", err.Error())
} else if reply != utils.OK {
t.Errorf("Calling ApierV1.ReloadCache received: %+v", reply)
@@ -304,7 +304,7 @@ func testDestManagCacheWithGetCost(t *testing.T) {
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
dests := make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 1 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))
@@ -333,7 +333,7 @@ func testDestManagCacheWithGetCost(t *testing.T) {
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
dests = make([]*engine.Destination, 0)
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
if err := destRPC.Call(utils.ApierV2GetDestinations, v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
} else if len(dests) != 1 {
t.Errorf("Calling ApierV2.GetDestinations got reply: %v", utils.ToIJSON(dests))

View File

@@ -106,7 +106,7 @@ func testDestinationGetCostFor1002(t *testing.T) {
Usage: "1m",
}
var rply *engine.EventCost
if err := tutorialRpc.Call("ApierV1.GetCost", attrs, &rply); err != nil {
if err := tutorialRpc.Call(utils.ApierV1GetCost, attrs, &rply); err != nil {
t.Error("Unexpected nil error received: ", err.Error())
} else if *rply.Cost != 0.01 {
t.Errorf("Unexpected cost received: %f", *rply.Cost)
@@ -123,7 +123,7 @@ func testDestinationGetCostFor1003(t *testing.T) {
Usage: "1m",
}
var rply *engine.EventCost
if err := tutorialRpc.Call("ApierV1.GetCost", attrs, &rply); err != nil {
if err := tutorialRpc.Call(utils.ApierV1GetCost, attrs, &rply); err != nil {
t.Error("Unexpected nil error received: ", err.Error())
} else if *rply.Cost != 0.3 {
t.Errorf("Unexpected cost received: %f", *rply.Cost)

View File

@@ -261,7 +261,7 @@ func testV1FltrPupulateThreshold(t *testing.T) {
attrsAA := &utils.AttrSetActions{ActionsId: "LOG", Actions: []*utils.TPAction{
{Identifier: utils.LOG},
}}
if err := fltrRpc.Call("ApierV2.SetActions", attrsAA, &result); err != nil && err.Error() != utils.ErrExists.Error() {
if err := fltrRpc.Call(utils.ApierV2SetActions, attrsAA, &result); err != nil && err.Error() != utils.ErrExists.Error() {
t.Error("Got error on ApierV2.SetActions: ", err.Error())
} else if result != utils.OK {
t.Errorf("Calling ApierV2.SetActions received: %s", result)
@@ -548,7 +548,7 @@ func testV1FltrAccounts(t *testing.T) {
attrsAA := &utils.AttrSetActions{ActionsId: "LOG", Actions: []*utils.TPAction{
{Identifier: utils.LOG},
}}
if err := fltrRpc.Call("ApierV2.SetActions", attrsAA, &result); err != nil && err.Error() != utils.ErrExists.Error() {
if err := fltrRpc.Call(utils.ApierV2SetActions, attrsAA, &result); err != nil && err.Error() != utils.ErrExists.Error() {
t.Error("Got error on ApierV2.SetActions: ", err.Error())
} else if result != utils.OK {
t.Errorf("Calling ApierV2.SetActions received: %s", result)

View File

@@ -108,7 +108,7 @@ package general_tests
// ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AttributeProfiles: 1,
// CdrStats: 0, Users: 0} // CdrStats and Users are 0 because deprecated. To be removed
// var args utils.AttrCacheStats
// if err := tutLocalRpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
// if err := tutLocalRpc.Call(utils.ApierV1GetCacheStats, args, &rcvStats); err != nil {
// t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
// } else if !reflect.DeepEqual(expectedStats, rcvStats) {
// t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", utils.ToJSON(expectedStats), utils.ToJSON(rcvStats))
@@ -120,7 +120,7 @@ package general_tests
// var rcvKeys utils.ArgsCache
// argsAPI := utils.ArgsCacheKeys{ArgsCache: utils.ArgsCache{
// DestinationIDs: &[]string{}, RatingPlanIDs: &[]string{"RP_RETAIL1", "RP_GENERIC", "NONEXISTENT"}}}
// if err := tutLocalRpc.Call("ApierV1.GetCacheKeys", argsAPI, &rcvKeys); err != nil {
// if err := tutLocalRpc.Call(utils.ApierV1GetCacheKeys, argsAPI, &rcvKeys); err != nil {
// t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
// } else {
// if rcvKeys.DestinationIDs == nil {
@@ -145,7 +145,7 @@ package general_tests
// if err != nil {
// t.Fatal(err)
// }
// if err := tutLocalRpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
// if err := tutLocalRpc.Call(utils.ApierV1GetCacheStats, args, &rcvStats); err != nil {
// t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
// } else if !reflect.DeepEqual(expectedStats, rcvStats) {
// t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats)
@@ -1186,7 +1186,7 @@ package general_tests
// func TestTutITSetAccount(t *testing.T) {
// var reply string
// attrs := &v2.AttrSetAccount{Tenant: "cgrates.org", Account: "tutacnt1", ActionPlanIDs: &[]string{"PACKAGE_10"}, ActionTriggerIDs: &[]string{"STANDARD_TRIGGERS"}, ReloadScheduler: true}
// if err := tutLocalRpc.Call("ApierV2.SetAccount", attrs, &reply); err != nil {
// if err := tutLocalRpc.Call(utils.ApierV2SetAccount, attrs, &reply); err != nil {
// t.Error("Got error on ApierV2.SetAccount: ", err.Error())
// } else if reply != "OK" {
// t.Errorf("Calling ApierV2.SetAccount received: %s", reply)
@@ -1225,7 +1225,7 @@ package general_tests
// }
// attrs = &v2.AttrSetAccount{Tenant: "cgrates.org", Account: "tutacnt1", ActionPlanIDs: &[]string{"PACKAGE_10"}, ActionTriggerIDs: &[]string{"STANDARD_TRIGGERS"}, AllowNegative: utils.BoolPointer(true), Disabled: utils.BoolPointer(true), ReloadScheduler: true}
// if err := tutLocalRpc.Call("ApierV2.SetAccount", attrs, &reply); err != nil {
// if err := tutLocalRpc.Call(utils.ApierV2SetAccount, attrs, &reply); err != nil {
// t.Error("Got error on ApierV2.SetAccount: ", err.Error())
// } else if reply != "OK" {
// t.Errorf("Calling ApierV2.SetAccount received: %s", reply)
@@ -1255,7 +1255,7 @@ package general_tests
// }
// attrs = &v2.AttrSetAccount{Tenant: "cgrates.org", Account: "tutacnt1", ActionPlanIDs: &[]string{"PACKAGE_1001"}, ActionTriggerIDs: &[]string{"CDRST1_WARN"}, AllowNegative: utils.BoolPointer(true), Disabled: utils.BoolPointer(true), ReloadScheduler: true}
// if err := tutLocalRpc.Call("ApierV2.SetAccount", attrs, &reply); err != nil {
// if err := tutLocalRpc.Call(utils.ApierV2SetAccount, attrs, &reply); err != nil {
// t.Error("Got error on ApierV2.SetAccount: ", err.Error())
// } else if reply != "OK" {
// t.Errorf("Calling ApierV2.SetAccount received: %s", reply)

View File

@@ -135,7 +135,7 @@ func testRPCMethodsAddData(t *testing.T) {
{Identifier: utils.DISABLE_ACCOUNT},
{Identifier: utils.LOG},
}}
if err := rpcRpc.Call("ApierV2.SetActions", attrsAA, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
if err := rpcRpc.Call(utils.ApierV2SetActions, attrsAA, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
t.Error("Got error on ApierV2.SetActions: ", err.Error())
} else if reply != utils.OK {
t.Errorf("Calling ApierV2.SetActions received: %s", reply)
@@ -145,7 +145,7 @@ func testRPCMethodsAddData(t *testing.T) {
{Identifier: utils.ENABLE_ACCOUNT},
{Identifier: utils.LOG},
}}
if err := rpcRpc.Call("ApierV2.SetActions", attrsAA2, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
if err := rpcRpc.Call(utils.ApierV2SetActions, attrsAA2, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
t.Error("Got error on ApierV2.SetActions: ", err.Error())
} else if reply != utils.OK {
t.Errorf("Calling ApierV2.SetActions received: %s", reply)

View File

@@ -298,7 +298,7 @@ func testRPCITLclStatusBcastRALs1Up(t *testing.T) {
/*
func TestRPCITStatusBcastCmd(t *testing.T) {
var stats utils.CacheStats
if err := rpcRAL1.Call("ApierV2.GetCacheStats", utils.AttrCacheStats{}, &stats); err != nil {
if err := rpcRAL1.Call(utils.ApierV2GetCacheStats, utils.AttrCacheStats{}, &stats); err != nil {
t.Error(err)
} else if stats.LastRatingLoadID != utils.NOT_AVAILABLE || stats.LastAccountingLoadID != utils.NOT_AVAILABLE {
t.Errorf("Received unexpected stats: %+v", stats)
@@ -311,17 +311,17 @@ func TestRPCITStatusBcastCmd(t *testing.T) {
t.Errorf("Empty loadId received, loadInstance: %+v", loadInst)
}
var reply string
if err := rpcPoolBroadcast.Call("ApierV1.ReloadCache", utils.AttrReloadCache{}, &reply); err != nil {
if err := rpcPoolBroadcast.Call(utils.ApierV1ReloadCache, utils.AttrReloadCache{}, &reply); err != nil {
t.Error("Got error on ApierV1.ReloadCache: ", err.Error())
} else if reply != utils.OK {
t.Error("Calling ApierV1.ReloadCache got reply: ", reply)
}
if err := rpcRAL1.Call("ApierV2.GetCacheStats", utils.AttrCacheStats{}, &stats); err != nil {
if err := rpcRAL1.Call(utils.ApierV2GetCacheStats, utils.AttrCacheStats{}, &stats); err != nil {
t.Error(err)
} else if stats.LastRatingLoadID != loadInst.RatingLoadID {
t.Errorf("Received unexpected stats: %+v vs %+v", stats, loadInst)
}
if err := rpcRAL2.Call("ApierV2.GetCacheStats", utils.AttrCacheStats{}, &stats); err != nil {
if err := rpcRAL2.Call(utils.ApierV2GetCacheStats, utils.AttrCacheStats{}, &stats); err != nil {
t.Error(err)
} else if stats.LastRatingLoadID != loadInst.RatingLoadID {
t.Errorf("Received unexpected stats: %+v vs %+v", stats, loadInst)

View File

@@ -121,7 +121,7 @@ func testSTICacheStats(t *testing.T) {
var rcvStats *utils.CacheStats
expectedStats := &utils.CacheStats{Destinations: 1, RatingPlans: 1, RatingProfiles: 1}
var args utils.AttrCacheStats
if err := stiRpc.Call("ApierV2.GetCacheStats", args, &rcvStats); err != nil {
if err := stiRpc.Call(utils.ApierV2GetCacheStats, args, &rcvStats); err != nil {
t.Error("Got error on ApierV2.GetCacheStats: ", err.Error())
} else if !reflect.DeepEqual(expectedStats, rcvStats) {
t.Errorf("Calling ApierV2.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats)
@@ -137,7 +137,7 @@ func testSTIProcessExternalCdr(t *testing.T) {
Usage: "15s", PDD: "7.0", ExtraFields: map[string]string{"CustomerNumber": "000000534", "ZipCode": ""},
}
var reply string
if err := stiRpc.Call("CdrsV2.ProcessExternalCdr", cdr, &reply); err != nil {
if err := stiRpc.Call(utils.CdrsV2ProcessExternalCdr, cdr, &reply); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if reply != utils.OK {
t.Error("Unexpected reply received: ", reply)

View File

@@ -146,13 +146,13 @@ func testTpBalanceCounter(t *testing.T) {
func testTpActionTriggers(t *testing.T) {
var atrs engine.ActionTriggers
if err := tpRPC.Call("ApierV1.GetActionTriggers", v1.AttrGetActionTriggers{GroupIDs: []string{}}, &atrs); err != nil {
if err := tpRPC.Call(utils.ApierV1GetActionTriggers, v1.AttrGetActionTriggers{GroupIDs: []string{}}, &atrs); err != nil {
t.Error("Got error on ApierV1.GetActionTriggers: ", err.Error())
} else if len(atrs) != 4 {
t.Errorf("Calling v1.GetActionTriggers got: %v", atrs)
}
var reply string
if err := tpRPC.Call("ApierV1.SetActionTrigger", v1.AttrSetActionTrigger{
if err := tpRPC.Call(utils.ApierV1SetActionTrigger, v1.AttrSetActionTrigger{
GroupID: "TestATR",
UniqueID: "Unique atr id",
BalanceID: utils.StringPointer("BID1"),
@@ -161,12 +161,12 @@ func testTpActionTriggers(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Calling v1.SetActionTrigger got: %v", reply)
}
if err := tpRPC.Call("ApierV1.GetActionTriggers", v1.AttrGetActionTriggers{GroupIDs: []string{}}, &atrs); err != nil {
if err := tpRPC.Call(utils.ApierV1GetActionTriggers, v1.AttrGetActionTriggers{GroupIDs: []string{}}, &atrs); err != nil {
t.Error(err)
} else if len(atrs) != 5 {
t.Errorf("Calling v1.GetActionTriggers got: %v", atrs)
}
if err := tpRPC.Call("ApierV1.GetActionTriggers", v1.AttrGetActionTriggers{GroupIDs: []string{"TestATR"}}, &atrs); err != nil {
if err := tpRPC.Call(utils.ApierV1GetActionTriggers, v1.AttrGetActionTriggers{GroupIDs: []string{"TestATR"}}, &atrs); err != nil {
t.Error("Got error on ApierV1.GetActionTriggers: ", err.Error())
} else if len(atrs) != 1 {
t.Errorf("Calling v1.GetActionTriggers got: %v", atrs)
@@ -252,7 +252,7 @@ func testTpZeroNegativeCost(t *testing.T) {
func testTpExecuteActionCgrRpc(t *testing.T) {
var reply string
if err := tpRPC.Call("ApierV2.ExecuteAction", utils.AttrExecuteAction{ActionsId: "RPC"}, &reply); err != nil {
if err := tpRPC.Call(utils.ApierV2ExecuteAction, utils.AttrExecuteAction{ActionsId: "RPC"}, &reply); err != nil {
t.Error("Got error on ApierV2.ExecuteAction: ", err.Error())
} else if reply != utils.OK {
t.Errorf("Calling ExecuteAction got reply: %s", reply)
@@ -266,7 +266,7 @@ func testTpExecuteActionCgrRpc(t *testing.T) {
func testTpExecuteActionCgrRpcAcc(t *testing.T) {
var reply string
if err := tpRPC.Call("ApierV2.ExecuteAction", utils.AttrExecuteAction{
if err := tpRPC.Call(utils.ApierV2ExecuteAction, utils.AttrExecuteAction{
Tenant: "cgrates.org",
Account: "1016",
ActionsId: "RPC_DEST",
@@ -277,7 +277,7 @@ func testTpExecuteActionCgrRpcAcc(t *testing.T) {
}
var dests []*engine.Destination
attrs := &v2.AttrGetDestinations{DestinationIDs: []string{}}
if err := tpRPC.Call("ApierV2.GetDestinations", attrs, &dests); err != nil {
if err := tpRPC.Call(utils.ApierV2GetDestinations, attrs, &dests); err != nil {
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
}
}
@@ -285,7 +285,7 @@ func testTpExecuteActionCgrRpcAcc(t *testing.T) {
// Deprecated
// func //(t *testing.T) {
// var reply string
// if err := tpRPC.Call("ApierV2.ExecuteAction", utils.AttrExecuteAction{
// if err := tpRPC.Call(utils.ApierV2ExecuteAction, utils.AttrExecuteAction{
// ActionsId: "RPC_CDRSTATS",
// }, &reply); err != nil {
// t.Error("Got error on ApierV2.ExecuteAction: ", err.Error())
@@ -294,14 +294,14 @@ func testTpExecuteActionCgrRpcAcc(t *testing.T) {
// }
// var queue engine.CDRStatsQueue
// time.Sleep(20 * time.Millisecond)
// if err := tpRPC.Call("CDRStatsV1.GetQueue", "qtest", &queue); err != nil {
// if err := tpRPC.Call(utils.CDRStatsV1GetQueue, "qtest", &queue); err != nil {
// t.Error("Got error on CDRStatsV1.GetQueue: ", err.Error())
// }
// }
func testTpCreateExecuteActionMatch(t *testing.T) {
var reply string
if err := tpRPC.Call("ApierV2.SetActions", utils.AttrSetActions{
if err := tpRPC.Call(utils.ApierV2SetActions, utils.AttrSetActions{
ActionsId: "PAYMENT_2056bd2fe137082970f97102b64e42fd",
Actions: []*utils.TPAction{
{
@@ -317,7 +317,7 @@ func testTpCreateExecuteActionMatch(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Calling ApierV2.SetActions got reply: %s", reply)
}
if err := tpRPC.Call("ApierV2.ExecuteAction", utils.AttrExecuteAction{
if err := tpRPC.Call(utils.ApierV2ExecuteAction, utils.AttrExecuteAction{
Tenant: "cgrates.org",
Account: "1015",
ActionsId: "PAYMENT_2056bd2fe137082970f97102b64e42fd",
@@ -326,7 +326,7 @@ func testTpCreateExecuteActionMatch(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Calling ExecuteAction got reply: %s", reply)
}
if err := tpRPC.Call("ApierV2.ExecuteAction", utils.AttrExecuteAction{
if err := tpRPC.Call(utils.ApierV2ExecuteAction, utils.AttrExecuteAction{
Tenant: "cgrates.org",
Account: "1015",
ActionsId: "PAYMENT_2056bd2fe137082970f97102b64e42fd",
@@ -349,7 +349,7 @@ func testTpCreateExecuteActionMatch(t *testing.T) {
func testTpSetRemoveActions(t *testing.T) {
var reply string
if err := tpRPC.Call("ApierV2.SetActions", utils.AttrSetActions{
if err := tpRPC.Call(utils.ApierV2SetActions, utils.AttrSetActions{
ActionsId: "TO_BE_DELETED",
Actions: []*utils.TPAction{
{
@@ -366,21 +366,21 @@ func testTpSetRemoveActions(t *testing.T) {
t.Errorf("Calling ApierV2.SetActions got reply: %s", reply)
}
actionsMap := make(map[string]engine.Actions)
if err := tpRPC.Call("ApierV2.GetActions", v2.AttrGetActions{
if err := tpRPC.Call(utils.ApierV2GetActions, v2.AttrGetActions{
ActionIDs: []string{"PAYMENT_2056bd2fe137082970f97102b64e42fd"},
}, &actionsMap); err != nil {
t.Error("Got error on ApierV2.GetActions: ", err.Error())
} else if len(actionsMap) != 1 {
t.Errorf("Calling ApierV2.GetActions got reply: %s", utils.ToIJSON(actionsMap))
}
if err := tpRPC.Call("ApierV2.RemoveActions", v1.AttrRemoveActions{
if err := tpRPC.Call(utils.ApierV2RemoveActions, v1.AttrRemoveActions{
ActionIDs: []string{"PAYMENT_2056bd2fe137082970f97102b64e42fd"},
}, &reply); err != nil {
t.Error("Got error on ApierV2.RemoveActions: ", err.Error())
} else if reply != utils.OK {
t.Errorf("Calling ApierV2.RemoveActions got reply: %s", reply)
}
if err := tpRPC.Call("ApierV2.GetActions", v2.AttrGetActions{
if err := tpRPC.Call(utils.ApierV2GetActions, v2.AttrGetActions{
ActionIDs: []string{"PAYMENT_2056bd2fe137082970f97102b64e42fd"},
}, &actionsMap); err == nil {
t.Error("no error on ApierV2.GetActions: ", err)
@@ -389,7 +389,7 @@ func testTpSetRemoveActions(t *testing.T) {
func testTpRemoveActionsRefenced(t *testing.T) {
actionsMap := make(map[string]engine.Actions)
if err := tpRPC.Call("ApierV2.GetActions", v2.AttrGetActions{
if err := tpRPC.Call(utils.ApierV2GetActions, v2.AttrGetActions{
ActionIDs: []string{"TOPUP_VOICE"},
}, &actionsMap); err != nil {
t.Error("Got error on ApierV2.GetActions: ", err.Error())
@@ -397,7 +397,7 @@ func testTpRemoveActionsRefenced(t *testing.T) {
t.Errorf("Calling ApierV2.GetActions got reply: %s", utils.ToIJSON(actionsMap))
}
var reply string
if err := tpRPC.Call("ApierV2.RemoveActions", v1.AttrRemoveActions{
if err := tpRPC.Call(utils.ApierV2RemoveActions, v1.AttrRemoveActions{
ActionIDs: []string{"TOPUP_VOICE"},
}, &reply); err != nil {
t.Error("Error on ApierV2.RemoveActions: ", err.Error())
@@ -405,7 +405,7 @@ func testTpRemoveActionsRefenced(t *testing.T) {
t.Errorf("Calling ApierV2.RemoveActions got reply: %s", reply)
}
/*
if err := tpRPC.Call("ApierV2.GetActions", v2.AttrGetActions{
if err := tpRPC.Call(utils.ApierV2GetActions, v2.AttrGetActions{
ActionIDs: []string{"PAYMENT_2056bd2fe137082970f97102b64e42fd"},
}, &actionsMap); err == nil {
t.Error("no error on ApierV2.GetActions: ", err)
@@ -422,7 +422,7 @@ func testTpApierResetAccountActionTriggers(t *testing.T) {
t.Skip("Skipping test since Executed is not yet true")
}
var reply string
if err := tpRPC.Call("ApierV2.ResetAccountActionTriggers", v1.AttrResetAccountActionTriggers{
if err := tpRPC.Call(utils.ApierV2ResetAccountActionTriggers, v1.AttrResetAccountActionTriggers{
Tenant: "cgrates.org",
Account: "1005",
GroupID: "STANDARD_TRIGGERS",

View File

@@ -112,7 +112,7 @@ func TestTutSMGLoadTariffPlanFromFolder(t *testing.T) {
// Check loaded stats
func TestTutSMGCacheStats(t *testing.T) {
var reply string
if err := tutSMGRpc.Call("CacheSv1.LoadCache", utils.AttrReloadCache{}, &reply); err != nil {
if err := tutSMGRpc.Call(utils.CacheSv1LoadCache, utils.AttrReloadCache{}, &reply); err != nil {
t.Error(err)
} else if reply != "OK" {
t.Error(reply)

View File

@@ -134,7 +134,7 @@ func testTutorialGetCost(t *testing.T) {
Usage: "2m10s",
}
var rply *engine.EventCost
if err := tutorialRpc.Call("ApierV1.GetCost", attrs, &rply); err != nil {
if err := tutorialRpc.Call(utils.ApierV1GetCost, attrs, &rply); err != nil {
t.Error("Unexpected nil error received: ", err.Error())
} else if *rply.Cost != 0.716900 {
t.Errorf("Unexpected cost received: %f", *rply.Cost)