Renamed AccountProfile in Accounts in all tests

This commit is contained in:
porosnicuadrian
2021-04-07 17:18:03 +03:00
committed by Dan Christian Bogos
parent 850a43433b
commit 1d70718d72
11 changed files with 145 additions and 146 deletions

View File

@@ -459,7 +459,7 @@ func TestAccountsDebit(t *testing.T) {
log.SetOutput(os.Stderr)
}
func TestV1AccountProfilesForEvent(t *testing.T) {
func TestV1AccountsForEvent(t *testing.T) {
engine.Cache.Clear(nil)
cfg := config.NewDefaultCGRConfig()
data := engine.NewInternalDB(nil, nil, true)
@@ -688,7 +688,7 @@ func TestV1DebitAbstracts(t *testing.T) {
//now we'll check the debited account
accPrf.Balances["AbstractBalance1"].Units = &utils.Decimal{decimal.New(39999999973, 0)}
if debitedAcc, err := accnts.dm.GetAccountProfile(accPrf.Tenant, accPrf.ID); err != nil {
if debitedAcc, err := accnts.dm.GetAccount(accPrf.Tenant, accPrf.ID); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(accPrf, debitedAcc) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(accPrf), utils.ToJSON(debitedAcc))
@@ -917,7 +917,7 @@ func TestV1DebitConcretes(t *testing.T) {
}
//now we will check the debited account
rcv, err := accnts.dm.GetAccountProfile("cgrates.org", "TestV1DebitAbstracts")
rcv, err := accnts.dm.GetAccount("cgrates.org", "TestV1DebitAbstracts")
if err != nil {
t.Error(err)
}
@@ -1137,7 +1137,7 @@ func TestV1ActionSetBalance(t *testing.T) {
},
},
}
if rcv, err := accnts.dm.GetAccountProfile(args.Tenant, args.AccountID); err != nil {
if rcv, err := accnts.dm.GetAccount(args.Tenant, args.AccountID); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expectedAcc, rcv) {
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expectedAcc), utils.ToJSON(rcv))

View File

@@ -95,7 +95,7 @@ func TestActSetAccountBalance(t *testing.T) {
}
if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err != nil {
t.Error(err)
} else if rcv, err := dm.GetAccountProfile("cgrates.org", acntID); err != nil {
} else if rcv, err := dm.GetAccount("cgrates.org", acntID); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(rcv, expectedAcc) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedAcc), utils.ToJSON(rcv))
@@ -144,7 +144,7 @@ func TestActSetAccount(t *testing.T) {
}
if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err != nil {
t.Error(err)
} else if rcv, err := dm.GetAccountProfile("cgrates.org", acntID); err != nil {
} else if rcv, err := dm.GetAccount("cgrates.org", acntID); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(rcv, expectedAcc) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedAcc), utils.ToJSON(rcv))

View File

@@ -476,7 +476,7 @@ func TestRestoreAccount(t *testing.T) { //coverage purpose
map[string]*decimal.Big{"CB2": decimal.New(100, 0)},
})
if rcv, err := dm.GetAccountProfile("cgrates.org", "1001"); err != nil {
if rcv, err := dm.GetAccount("cgrates.org", "1001"); err != nil {
t.Error(err)
} else if len(rcv.Balances) != 2 {
t.Errorf("Unexpected number of balances received")
@@ -582,7 +582,7 @@ func TestDebitFromBothBalances(t *testing.T) {
//AccountS
accnts := NewAccountS(cfg, fltr, connMngr, dm)
accPrf := &utils.AccountProfile{
accPrf := &utils.Account{
Tenant: "cgrates.org",
ID: "1002",
FilterIDs: []string{"*string:~*req.Account:2003"},
@@ -620,7 +620,7 @@ func TestDebitFromBothBalances(t *testing.T) {
},
}
if err := dm.SetAccountProfile(accPrf, true); err != nil {
if err := dm.SetAccount(accPrf, true); err != nil {
t.Error(err)
}
@@ -681,13 +681,13 @@ func TestDebitFromBothBalances(t *testing.T) {
accPrf.Balances["AbstractBalance"].Units = utils.NewDecimal(1200, 0)
accPrf.Balances["ConcreteBalance2"].Units = utils.NewDecimal(49999999997, 9)
//as we debited, the account is changed
if rcvAcc, err := dm.GetAccountProfile(accPrf.Tenant, accPrf.ID); err != nil {
if rcvAcc, err := dm.GetAccount(accPrf.Tenant, accPrf.ID); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(rcvAcc, accPrf) {
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(accPrf), utils.ToJSON(rcvAcc))
}
if err := dm.RemoveAccountProfile(accPrf.Tenant, accPrf.ID,
if err := dm.RemoveAccount(accPrf.Tenant, accPrf.ID,
utils.NonTransactional, true); err != nil {
t.Error(err)
} else if err := dm.RemoveRateProfile(rtPrf.Tenant, rtPrf.ID,

View File

@@ -129,7 +129,7 @@ func testAccountSv1LoadFromFolder(t *testing.T) {
}
func testAccountSv1AccountProfilesForEvent(t *testing.T) {
eAcnts := []*utils.AccountProfile{
eAcnts := []*utils.Account{
{
Tenant: "cgrates.org",
ID: "1001",
@@ -211,12 +211,12 @@ func testAccountSv1AccountProfilesForEvent(t *testing.T) {
ThresholdIDs: []string{utils.MetaNone},
},
}
var acnts []*utils.AccountProfile
var acnts []*utils.Account
if err := acntSRPC.Call(utils.AccountSv1AccountProfilesForEvent,
&utils.ArgsAccountsForEvent{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
ID: "testAccountSv1AccountProfileForEvent",
ID: "testAccountSv1AccountForEvent",
Event: map[string]interface{}{
utils.AccountField: "1001",
}}}, &acnts); err != nil {
@@ -243,7 +243,7 @@ func testAccountSv1MaxAbstracts(t *testing.T) {
}
// Make sure we did not Debit anything from Account
eAcnt := &utils.AccountProfile{
eAcnt := &utils.Account{
Tenant: "cgrates.org",
ID: "1001",
FilterIDs: []string{"*string:~*req.Account:1001"},
@@ -324,7 +324,7 @@ func testAccountSv1MaxAbstracts(t *testing.T) {
ThresholdIDs: []string{utils.MetaNone},
}
var reply *utils.AccountProfile
var reply *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile,
utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}}, &reply); err != nil {
t.Fatal(err)
@@ -350,7 +350,7 @@ func testAccountSv1DebitAbstracts(t *testing.T) {
}
// Make sure we debit the right units from Account
eAcnt := &utils.AccountProfile{
eAcnt := &utils.Account{
Tenant: "cgrates.org",
ID: "1001",
FilterIDs: []string{"*string:~*req.Account:1001"},
@@ -431,7 +431,7 @@ func testAccountSv1DebitAbstracts(t *testing.T) {
ThresholdIDs: []string{utils.MetaNone},
}
var reply *utils.AccountProfile
var reply *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile,
utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}}, &reply); err != nil {
t.Fatal(err)
@@ -441,8 +441,8 @@ func testAccountSv1DebitAbstracts(t *testing.T) {
}
func testAccountSv1SimpleDebit(t *testing.T) {
accPrfAPI := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "CustomAccount",
FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
@@ -477,11 +477,11 @@ func testAccountSv1SimpleDebit(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
var err error
var convAcc *utils.AccountProfile
if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
var convAcc *utils.Account
if convAcc, err = accPrfAPI.AsAccount(); err != nil {
t.Error(err)
}
var reply2 *utils.AccountProfile
var reply2 *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
t.Error(err)
@@ -512,8 +512,8 @@ func testAccountSv1SimpleDebit(t *testing.T) {
}
func testAccountSv1DebitMultipleAcc(t *testing.T) {
accPrfAPI := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "CustomAccount",
FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
@@ -542,11 +542,11 @@ func testAccountSv1DebitMultipleAcc(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
var err error
var convAcc *utils.AccountProfile
if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
var convAcc *utils.Account
if convAcc, err = accPrfAPI.AsAccount(); err != nil {
t.Error(err)
}
var reply2 *utils.AccountProfile
var reply2 *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
t.Error(err)
@@ -554,8 +554,8 @@ func testAccountSv1DebitMultipleAcc(t *testing.T) {
t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
}
accPrfAPI2 := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI2 := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "CustomAccount2",
FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
@@ -582,8 +582,8 @@ func testAccountSv1DebitMultipleAcc(t *testing.T) {
} else if reply != utils.OK {
t.Error("Unexpected reply returned", reply)
}
var convAcc2 *utils.AccountProfile
if convAcc2, err = accPrfAPI2.AsAccountProfile(); err != nil {
var convAcc2 *utils.Account
if convAcc2, err = accPrfAPI2.AsAccount(); err != nil {
t.Fatal(err)
}
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
@@ -623,8 +623,8 @@ func testAccountSv1DebitMultipleAcc(t *testing.T) {
}
func testAccountSv1DebitMultipleAccLimited(t *testing.T) {
accPrfAPI := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "CustomAccount",
FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
@@ -656,11 +656,11 @@ func testAccountSv1DebitMultipleAccLimited(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
var err error
var convAcc *utils.AccountProfile
if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
var convAcc *utils.Account
if convAcc, err = accPrfAPI.AsAccount(); err != nil {
t.Error(err)
}
var reply2 *utils.AccountProfile
var reply2 *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
t.Error(err)
@@ -668,8 +668,8 @@ func testAccountSv1DebitMultipleAccLimited(t *testing.T) {
t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
}
accPrfAPI2 := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI2 := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "CustomAccount2",
FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
@@ -696,8 +696,8 @@ func testAccountSv1DebitMultipleAccLimited(t *testing.T) {
} else if reply != utils.OK {
t.Error("Unexpected reply returned", reply)
}
var convAcc2 *utils.AccountProfile
if convAcc2, err = accPrfAPI2.AsAccountProfile(); err != nil {
var convAcc2 *utils.Account
if convAcc2, err = accPrfAPI2.AsAccount(); err != nil {
t.Fatal(err)
}
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
@@ -737,8 +737,8 @@ func testAccountSv1DebitMultipleAccLimited(t *testing.T) {
}
func testAccountSv1DebitWithAttributeSandRateS(t *testing.T) {
accPrfAPI := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "ACC_WITH_ATTRIBUTES",
FilterIDs: []string{"*string:~*req.Account:ACC_WITH_ATTRIBUTES"},
@@ -768,11 +768,11 @@ func testAccountSv1DebitWithAttributeSandRateS(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
var err error
var convAcc *utils.AccountProfile
if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
var convAcc *utils.Account
if convAcc, err = accPrfAPI.AsAccount(); err != nil {
t.Error(err)
}
var reply2 *utils.AccountProfile
var reply2 *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_ATTRIBUTES"}}, &reply2); err != nil {
t.Error(err)
@@ -834,8 +834,8 @@ func testAccountSv1DebitWithAttributeSandRateS(t *testing.T) {
}
func testAccountSv1DebitWithRateS(t *testing.T) {
accPrfAPI := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "ACC_WITH_RATES",
FilterIDs: []string{"*string:~*req.Account:ACC_WITH_RATES"},
@@ -864,11 +864,11 @@ func testAccountSv1DebitWithRateS(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
var err error
var convAcc *utils.AccountProfile
if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
var convAcc *utils.Account
if convAcc, err = accPrfAPI.AsAccount(); err != nil {
t.Error(err)
}
var reply2 *utils.AccountProfile
var reply2 *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_RATES"}}, &reply2); err != nil {
t.Error(err)
@@ -931,8 +931,8 @@ func testAccountSv1DebitWithRateS(t *testing.T) {
}
func testAccountSv1DebitWithRateS2(t *testing.T) {
accPrfAPI := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
accPrfAPI := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "ACC_WITH_RATES2",
FilterIDs: []string{"*string:~*req.Account:ACC_WITH_RATES2"},
@@ -968,11 +968,11 @@ func testAccountSv1DebitWithRateS2(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
var err error
var convAcc *utils.AccountProfile
if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
var convAcc *utils.Account
if convAcc, err = accPrfAPI.AsAccount(); err != nil {
t.Error(err)
}
var reply2 *utils.AccountProfile
var reply2 *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_RATES2"}}, &reply2); err != nil {
t.Error(err)
@@ -1035,8 +1035,8 @@ func testAccountSv1DebitWithRateS2(t *testing.T) {
}
func testAccountSv1MaxConcretes(t *testing.T) {
apiAccPrf = &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
apiAccPrf = &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "1004",
FilterIDs: []string{"*string:~*req.Account:1004"},
@@ -1095,11 +1095,11 @@ func testAccountSv1MaxConcretes(t *testing.T) {
t.Error("Unexpected reply returned", reply)
}
exp, err := apiAccPrf.AsAccountProfile()
exp, err := apiAccPrf.AsAccount()
if err != nil {
t.Error(err)
}
var result *utils.AccountProfile
var result *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
t.Error(err)
@@ -1124,7 +1124,7 @@ func testAccountSv1MaxConcretes(t *testing.T) {
}
//make sure we did not Debit from our Account
exp, err = apiAccPrf.AsAccountProfile()
exp, err = apiAccPrf.AsAccount()
if err != nil {
t.Error(err)
}
@@ -1153,7 +1153,7 @@ func testAccountSv1DebitConcretes(t *testing.T) {
t.Errorf("received usage: %v", *eEc.Concretes)
}
exp := &utils.AccountProfile{
exp := &utils.Account{
Tenant: "cgrates.org",
ID: "1004",
FilterIDs: []string{"*string:~*req.Account:1004"},
@@ -1216,7 +1216,7 @@ func testAccountSv1DebitConcretes(t *testing.T) {
ThresholdIDs: []string{utils.MetaNone},
}
var result *utils.AccountProfile
var result *utils.Account
//As we debit, our Account balances are changed now
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
@@ -1227,7 +1227,7 @@ func testAccountSv1DebitConcretes(t *testing.T) {
}
func testAccountSv1ActionSetBalance(t *testing.T) {
expectedSetBalance := &utils.AccountProfile{
expectedSetBalance := &utils.Account{
Tenant: "cgrates.org",
ID: "1004",
FilterIDs: []string{"*string:~*req.Account:1004"},
@@ -1336,7 +1336,7 @@ func testAccountSv1ActionSetBalance(t *testing.T) {
t.Errorf("Unexpected reply returned")
}
var result *utils.AccountProfile
var result *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
t.Error(err)
@@ -1356,7 +1356,7 @@ func testAccountSv1ActionRemoveBalance(t *testing.T) {
t.Errorf("Unexpected reply returned")
}
expectedSetBalance := &utils.AccountProfile{
expectedSetBalance := &utils.Account{
Tenant: "cgrates.org",
ID: "1004",
FilterIDs: []string{"*string:~*req.Account:1004"},
@@ -1406,7 +1406,7 @@ func testAccountSv1ActionRemoveBalance(t *testing.T) {
ThresholdIDs: []string{"TH_ID1"},
}
var result *utils.AccountProfile
var result *utils.Account
if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
t.Error(err)

View File

@@ -723,15 +723,15 @@ func testFullRemoteITAction(t *testing.T) {
func testFullRemoteITAccount(t *testing.T) {
// verify for not found in internal
var reply *utils.AccountProfile
var reply *utils.Account
if err := fullRemInternalRPC.Call(utils.APIerSv1GetAccountProfile,
utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}},
&reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Fatal(err)
}
apiAccPrf := &utils.APIAccountProfileWithOpts{
APIAccountProfile: &utils.APIAccountProfile{
apiAccPrf := &utils.APIAccountWithOpts{
APIAccount: &utils.APIAccount{
Tenant: "cgrates.org",
ID: "1001",
Weights: ";20",
@@ -787,7 +787,7 @@ func testFullRemoteITAccount(t *testing.T) {
t.Error("Unexpected reply returned", replySet)
}
accPrf, err := apiAccPrf.AsAccountProfile()
accPrf, err := apiAccPrf.AsAccount()
if err != nil {
t.Error(err)
}
@@ -808,7 +808,7 @@ func testFullRemoteITAccount(t *testing.T) {
t.Error("Unexpected reply returned", replySet)
}
accPrf, err = apiAccPrf.AsAccountProfile()
accPrf, err = apiAccPrf.AsAccount()
if err != nil {
t.Error(err)
}

View File

@@ -36,7 +36,7 @@ var (
tpAcctPrfCfgPath string
tpAcctPrfCfg *config.CGRConfig
tpAcctPrfRPC *rpc.Client
tpAcctPrf *utils.TPAccountProfile
tpAcctPrf *utils.TPAccount
tpAcctPrfDelay int
tpAcctPrfConfigDIR string //run tests for specific configuration
)
@@ -110,7 +110,7 @@ func testTPAcctPrfRPCConn(t *testing.T) {
}
func testTPAcctPrfGetTPAcctPrfBeforeSet(t *testing.T) {
var reply *utils.TPAccountProfile
var reply *utils.TPAccount
if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfile,
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
@@ -118,7 +118,7 @@ func testTPAcctPrfGetTPAcctPrfBeforeSet(t *testing.T) {
}
func testTPAcctPrfSetTPAcctPrf(t *testing.T) {
tpAcctPrf = &utils.TPAccountProfile{
tpAcctPrf = &utils.TPAccount{
TPid: "TP1",
Tenant: "cgrates.org",
ID: "1001",
@@ -142,7 +142,7 @@ func testTPAcctPrfSetTPAcctPrf(t *testing.T) {
}
func testTPAcctPrfGetTPAcctPrfAfterSet(t *testing.T) {
var reply *utils.TPAccountProfile
var reply *utils.TPAccount
if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfile,
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"}, &reply); err != nil {
t.Fatal(err)
@@ -156,7 +156,7 @@ func testTPAcctPrfGetTPAcctPrfIDs(t *testing.T) {
var result []string
expectedTPID := []string{"cgrates.org:1001"}
if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfileIDs,
&AttrGetTPAccountProfileIDs{TPid: "TP1"}, &result); err != nil {
&AttrGetTPAccountIDs{TPid: "TP1"}, &result); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expectedTPID, result) {
t.Errorf("Expecting: %+v, received: %+v", expectedTPID, result)
@@ -181,8 +181,8 @@ func testTPAcctPrfUpdateTPAcctBal(t *testing.T) {
}
func testTPAcctPrfGetTPAcctBalAfterUpdate(t *testing.T) {
var reply *utils.TPAccountProfile
revTPAcctPrf := &utils.TPAccountProfile{
var reply *utils.TPAccount
revTPAcctPrf := &utils.TPAccount{
TPid: "TP1",
Tenant: "cgrates.org",
ID: "1001",
@@ -218,7 +218,7 @@ func testTPAcctPrfRemTPAcctPrf(t *testing.T) {
}
func testTPAcctPrfGetTPAcctPrfAfterRemove(t *testing.T) {
var reply *utils.TPAccountProfile
var reply *utils.TPAccount
if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfile,
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"},
&reply); err == nil || err.Error() != utils.ErrNotFound.Error() {

View File

@@ -83,7 +83,7 @@ func init() {
if err := csvr.LoadActionProfiles(); err != nil {
log.Print("error in LoadActionProfiles: ", err)
}
if err := csvr.LoadAccountProfiles(); err != nil {
if err := csvr.LoadAccounts(); err != nil {
log.Print("error in LoadActionProfiles: ", err)
}
if err := csvr.WriteToDatabase(false, false); err != nil {
@@ -857,8 +857,8 @@ func TestLoadThresholds(t *testing.T) {
}
}
func TestLoadAccountProfiles(t *testing.T) {
expected := &utils.TPAccountProfile{
func TestLoadAccount(t *testing.T) {
expected := &utils.TPAccount{
TPid: testTPID,
Tenant: "cgrates.org",
ID: "1001",

View File

@@ -5299,8 +5299,8 @@ func TestModelHelpersCSVLoadErrorBool(t *testing.T) {
}
}
func TestAccountProfileMdlsCSVHeader(t *testing.T) {
testStruct := AccountProfileMdls{{
func TestAccountMdlsCSVHeader(t *testing.T) {
testStruct := AccountMdls{{
Tpid: "TEST_TPID",
Tenant: "cgrates.org",
ID: "ResGroup1",
@@ -5320,8 +5320,8 @@ func TestAccountProfileMdlsCSVHeader(t *testing.T) {
}
}
func TestAccountProfileMdlsAsTPAccountProfile(t *testing.T) {
testStruct := AccountProfileMdls{{
func TestAccountMdlsAsTPAccount(t *testing.T) {
testStruct := AccountMdls{{
PK: 0,
Tpid: "TEST_TPID",
Tenant: "cgrates.org",
@@ -5338,7 +5338,7 @@ func TestAccountProfileMdlsAsTPAccountProfile(t *testing.T) {
ThresholdIDs: "WARN_RES1",
},
}
exp := []*utils.TPAccountProfile{
exp := []*utils.TPAccount{
{
TPid: "TEST_TPID",
Tenant: "cgrates.org",
@@ -5362,7 +5362,7 @@ func TestAccountProfileMdlsAsTPAccountProfile(t *testing.T) {
ThresholdIDs: []string{"WARN_RES1"},
},
}
result, err := testStruct.AsTPAccountProfile()
result, err := testStruct.AsTPAccount()
if err != nil {
t.Fatal(err)
}
@@ -5373,8 +5373,8 @@ func TestAccountProfileMdlsAsTPAccountProfile(t *testing.T) {
}
}
func TestAccountProfileMdlsAsTPAccountProfileCase2(t *testing.T) {
testStruct := AccountProfileMdls{{
func TestAccountMdlsAsTPAccountCase2(t *testing.T) {
testStruct := AccountMdls{{
PK: 0,
Tpid: "TEST_TPID",
Tenant: "cgrates.org",
@@ -5390,7 +5390,7 @@ func TestAccountProfileMdlsAsTPAccountProfileCase2(t *testing.T) {
ThresholdIDs: "WARN_RES1",
},
}
exp := []*utils.TPAccountProfile{
exp := []*utils.TPAccount{
{
TPid: "TEST_TPID",
Tenant: "cgrates.org",
@@ -5412,7 +5412,7 @@ func TestAccountProfileMdlsAsTPAccountProfileCase2(t *testing.T) {
ThresholdIDs: []string{"WARN_RES1"},
},
}
result, err := testStruct.AsTPAccountProfile()
result, err := testStruct.AsTPAccount()
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(exp, result) {
@@ -5420,8 +5420,8 @@ func TestAccountProfileMdlsAsTPAccountProfileCase2(t *testing.T) {
}
}
func TestAccountProfileMdlsAsTPAccountProfileError(t *testing.T) {
testStruct := AccountProfileMdls{
func TestAccountMdlsAsTPAccountError(t *testing.T) {
testStruct := AccountMdls{
{
PK: 0,
Tpid: "TEST_TPID",
@@ -5432,32 +5432,32 @@ func TestAccountProfileMdlsAsTPAccountProfileError(t *testing.T) {
},
}
expectedErr := "invlid key: <AN;INVALID;COST;INCREMENT;VALUE> for BalanceCostIncrements"
if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
if _, err := testStruct.AsTPAccount(); err == nil || err.Error() != expectedErr {
t.Errorf("Expected %+v, received %+v", expectedErr, err)
}
testStruct[0].BalanceCostIncrements = ";20;not_float;10"
expectedErr = "strconv.ParseFloat: parsing \"not_float\": invalid syntax"
if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
if _, err := testStruct.AsTPAccount(); err == nil || err.Error() != expectedErr {
t.Errorf("Expected %+v, received %+v", expectedErr, err)
}
testStruct[0].BalanceCostIncrements = utils.EmptyString
testStruct[0].BalanceUnitFactors = "NOT;A;VALUE"
expectedErr = "invlid key: <NOT;A;VALUE> for BalanceUnitFactors"
if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
if _, err := testStruct.AsTPAccount(); err == nil || err.Error() != expectedErr {
t.Errorf("Expected %+v, received %+v", expectedErr, err)
}
testStruct[0].BalanceUnitFactors = ";float"
expectedErr = "strconv.ParseFloat: parsing \"float\": invalid syntax"
if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
if _, err := testStruct.AsTPAccount(); err == nil || err.Error() != expectedErr {
t.Errorf("Expected %+v, received %+v", expectedErr, err)
}
}
func TestAPItoModelTPAccountProfile(t *testing.T) {
testStruct := &utils.TPAccountProfile{
func TestAPItoModelTPAccount(t *testing.T) {
testStruct := &utils.TPAccount{
TPid: "TEST_TPID",
Tenant: "cgrates.org",
ID: "ResGroup1",
@@ -5479,7 +5479,7 @@ func TestAPItoModelTPAccountProfile(t *testing.T) {
},
ThresholdIDs: []string{"WARN_RES1"},
}
exp := AccountProfileMdls{{
exp := AccountMdls{{
Tpid: "TEST_TPID",
Tenant: "cgrates.org",
ID: "ResGroup1",
@@ -5493,14 +5493,14 @@ func TestAPItoModelTPAccountProfile(t *testing.T) {
BalanceUnits: 3600000000000,
ThresholdIDs: "WARN_RES1",
}}
result := APItoModelTPAccountProfile(testStruct)
result := APItoModelTPAccount(testStruct)
if !reflect.DeepEqual(exp, result) {
t.Errorf("Expecting: %+v,\nreceived: %+v", utils.ToJSON(exp), utils.ToJSON(result))
}
}
func TestAPItoModelTPAccountProfileNoBalance(t *testing.T) {
testStruct := &utils.TPAccountProfile{
func TestAPItoModelTPAccountNoBalance(t *testing.T) {
testStruct := &utils.TPAccount{
TPid: "TEST_TPID",
Tenant: "cgrates.org",
ID: "ResGroup1",
@@ -5512,15 +5512,15 @@ func TestAPItoModelTPAccountProfileNoBalance(t *testing.T) {
Weights: "10.0",
ThresholdIDs: []string{"WARN_RES1"},
}
var exp AccountProfileMdls = nil
result := APItoModelTPAccountProfile(testStruct)
var exp AccountMdls = nil
result := APItoModelTPAccount(testStruct)
if !reflect.DeepEqual(exp, result) {
t.Errorf("Expecting: %+v,\nreceived: %+v", utils.ToJSON(exp), utils.ToJSON(result))
}
}
func TestAPItoModelTPAccountProfileCase2(t *testing.T) {
testStruct := &utils.TPAccountProfile{
func TestAPItoModelTPAccountCase2(t *testing.T) {
testStruct := &utils.TPAccount{
TPid: "TEST_TPID",
Tenant: "cgrates.org",
ID: "ResGroup1",
@@ -5567,7 +5567,7 @@ func TestAPItoModelTPAccountProfileCase2(t *testing.T) {
},
ThresholdIDs: []string{"WARN_RES1", "WARN_RES2"},
}
exp := AccountProfileMdls{{
exp := AccountMdls{{
Tpid: "TEST_TPID",
Tenant: "cgrates.org",
ID: "ResGroup1",
@@ -5588,14 +5588,14 @@ func TestAPItoModelTPAccountProfileCase2(t *testing.T) {
sort.Strings(testStruct.FilterIDs)
sort.Strings(testStruct.ThresholdIDs)
sort.Strings(testStruct.Balances["VoiceBalance"].FilterIDs)
result := APItoModelTPAccountProfile(testStruct)
result := APItoModelTPAccount(testStruct)
if !reflect.DeepEqual(exp, result) {
t.Errorf("Expecting: %+v,\nreceived: %+v", utils.ToJSON(exp), utils.ToJSON(result))
}
}
func TestApitoAccountProfileCase2(t *testing.T) {
testStruct := &utils.TPAccountProfile{
func TestApitoAccountCase2(t *testing.T) {
testStruct := &utils.TPAccount{
Tenant: "cgrates.org",
ID: "ResGroup1",
FilterIDs: []string{"FLTR_RES_GR1"},
@@ -5648,7 +5648,7 @@ func TestApitoAccountProfileCase2(t *testing.T) {
}},
ThresholdIDs: []string{"WARN_RES1"},
}
result, err := APItoAccountProfile(testStruct, "")
result, err := APItoAccount(testStruct, "")
if err != nil {
t.Errorf("Expecting: <nil>,\nreceived: <%+v>", err)
}
@@ -5657,8 +5657,8 @@ func TestApitoAccountProfileCase2(t *testing.T) {
}
}
func TestApiToAccountProfileWeightsError(t *testing.T) {
testStruct := &utils.TPAccountProfile{
func TestApiToAccountWeightsError(t *testing.T) {
testStruct := &utils.TPAccount{
Tenant: "cgrates.org",
Weights: "10",
Balances: map[string]*utils.TPAccountBalance{
@@ -5669,19 +5669,19 @@ func TestApiToAccountProfileWeightsError(t *testing.T) {
},
}
expectedErr := "invalid DynamicWeight format for string <10>"
if _, err := APItoAccountProfile(testStruct, ""); err == nil || err.Error() != expectedErr {
if _, err := APItoAccount(testStruct, ""); err == nil || err.Error() != expectedErr {
t.Errorf("Expecting: %+v,\nreceived: <%+v>", expectedErr, err)
}
testStruct.Weights = ";10"
testStruct.Balances["VoiceBalance"].Weights = "10"
if _, err := APItoAccountProfile(testStruct, ""); err == nil || err.Error() != expectedErr {
if _, err := APItoAccount(testStruct, ""); err == nil || err.Error() != expectedErr {
t.Errorf("Expecting: %+v,\nreceived: <%+v>", expectedErr, err)
}
}
func TestApitoAccountProfileCaseTimeError(t *testing.T) {
testStruct := &utils.TPAccountProfile{
func TestApitoAccountCaseTimeError(t *testing.T) {
testStruct := &utils.TPAccount{
Tenant: "cgrates.org",
ID: "ResGroup1",
FilterIDs: []string{"FLTR_RES_GR1"},
@@ -5702,14 +5702,14 @@ func TestApitoAccountProfileCaseTimeError(t *testing.T) {
},
ThresholdIDs: []string{"WARN_RES1"},
}
_, err := APItoAccountProfile(testStruct, "")
_, err := APItoAccount(testStruct, "")
if err == nil || err.Error() != "Unsupported time format" {
t.Errorf("Expecting: <Unsupported time format>,\nreceived: <%+v>", err)
}
}
func TestApitoAccountProfileCaseTimeError2(t *testing.T) {
testStruct := &utils.TPAccountProfile{
func TestApitoAccountCaseTimeError2(t *testing.T) {
testStruct := &utils.TPAccount{
Tenant: "cgrates.org",
ID: "ResGroup1",
FilterIDs: []string{"FLTR_RES_GR1"},
@@ -5730,7 +5730,7 @@ func TestApitoAccountProfileCaseTimeError2(t *testing.T) {
},
ThresholdIDs: []string{"WARN_RES1"},
}
_, err := APItoAccountProfile(testStruct, "")
_, err := APItoAccount(testStruct, "")
if err == nil || err.Error() != "malformed option for ActionProfile <cgrates.org:ResGroup1> for action <VoiceBalance>" {
t.Errorf("Expecting: <malformed option for ActionProfile <cgrates.org:ResGroup1> for action <VoiceBalance>>,\nreceived: <%+v>", err)
}
@@ -5808,7 +5808,7 @@ func TestModelHelpersActionProfileToAPICase2(t *testing.T) {
}
}
func TestModelHelpersAccountProfileToAPI(t *testing.T) {
func TestModelHelpersAccountToAPI(t *testing.T) {
testStruct := &utils.Account{
Tenant: "cgrates.org",
ID: "RP1",
@@ -5855,7 +5855,7 @@ func TestModelHelpersAccountProfileToAPI(t *testing.T) {
}},
ThresholdIDs: []string{"test_thrs"},
}
expStruct := &utils.TPAccountProfile{
expStruct := &utils.TPAccount{
Tenant: "cgrates.org",
ID: "RP1",
FilterIDs: []string{"test_filterId"},
@@ -5892,7 +5892,7 @@ func TestModelHelpersAccountProfileToAPI(t *testing.T) {
},
ThresholdIDs: []string{"test_thrs"},
}
if result := AccountProfileToAPI(testStruct); !reflect.DeepEqual(result, expStruct) {
if result := AccountToAPI(testStruct); !reflect.DeepEqual(result, expStruct) {
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result))
}
}

View File

@@ -140,12 +140,12 @@ func testStorDBitIsDBEmpty(t *testing.T) {
func testStorDBitCRUDTPAccountProfiles(t *testing.T) {
//READ
if _, err := storDB.GetTPAccountProfiles("sub_ID1", utils.EmptyString, "TEST_ID1"); err != utils.ErrNotFound {
if _, err := storDB.GetTPAccounts("sub_ID1", utils.EmptyString, "TEST_ID1"); err != utils.ErrNotFound {
t.Error(err)
}
//WRITE
var actPrf = []*utils.TPAccountProfile{
var actPrf = []*utils.TPAccount{
{
TPid: testTPID,
Tenant: "cgrates.org",
@@ -181,12 +181,12 @@ func testStorDBitCRUDTPAccountProfiles(t *testing.T) {
ThresholdIDs: []string{utils.MetaNone},
},
}
if err := storDB.SetTPAccountProfiles(actPrf); err != nil {
if err := storDB.SetTPAccounts(actPrf); err != nil {
t.Error(err)
}
//READ
rcv, err := storDB.GetTPAccountProfiles(actPrf[0].TPid, utils.EmptyString, utils.EmptyString)
rcv, err := storDB.GetTPAccounts(actPrf[0].TPid, utils.EmptyString, utils.EmptyString)
if err != nil {
t.Error(err)
}
@@ -197,9 +197,9 @@ func testStorDBitCRUDTPAccountProfiles(t *testing.T) {
//UPDATE AND READ
actPrf[0].FilterIDs = []string{"*string:~*req.Account:1007"}
if err := storDB.SetTPAccountProfiles(actPrf); err != nil {
if err := storDB.SetTPAccounts(actPrf); err != nil {
t.Error(err)
} else if rcv, err := storDB.GetTPAccountProfiles(actPrf[0].TPid,
} else if rcv, err := storDB.GetTPAccounts(actPrf[0].TPid,
utils.EmptyString, utils.EmptyString); err != nil {
t.Error(err)
} else if !(reflect.DeepEqual(rcv[0], actPrf[0])) {

View File

@@ -38,7 +38,7 @@ func (m *Migrator) migrateCurrentAccountProfiles() (err error) {
if len(tntID) < 2 {
return fmt.Errorf("Invalid key <%s> when migrating from account profiles", id)
}
ap, err := m.dmIN.DataManager().GetAccountProfile(tntID[0], tntID[1])
ap, err := m.dmIN.DataManager().GetAccount(tntID[0], tntID[1])
if err != nil {
return err
}
@@ -48,7 +48,7 @@ func (m *Migrator) migrateCurrentAccountProfiles() (err error) {
if err := m.dmOut.DataManager().SetAccount(ap, true); err != nil {
return err
}
if err := m.dmIN.DataManager().RemoveAccountProfile(tntID[0], tntID[1], utils.NonTransactional, false); err != nil {
if err := m.dmIN.DataManager().RemoveAccount(tntID[0], tntID[1], utils.NonTransactional, false); err != nil {
return err
}
m.stats[utils.AccountProfilesString]++

View File

@@ -67,7 +67,7 @@ func TestCloneBalance(t *testing.T) {
}
}
func TestCloneAccountProfile(t *testing.T) {
func TestCloneAccount(t *testing.T) {
actPrf := &Account{
Tenant: "cgrates.org",
ID: "Profile_id1",
@@ -128,7 +128,7 @@ func TestCloneAccountProfile(t *testing.T) {
}
}
func TestTenantIDAccountProfile(t *testing.T) {
func TestTenantIDAccount(t *testing.T) {
actPrf := &Account{
Tenant: "cgrates.org",
ID: "test_ID1",
@@ -139,7 +139,7 @@ func TestTenantIDAccountProfile(t *testing.T) {
}
}
func TestAccountProfileAsAccountProfile(t *testing.T) {
func TestAPIAccountAsAccount(t *testing.T) {
apiAccPrf := &APIAccount{
Tenant: "cgrates.org",
ID: "test_ID1",
@@ -191,7 +191,7 @@ func TestAccountProfileAsAccountProfile(t *testing.T) {
}
}
func TestAsAccountProfileError(t *testing.T) {
func TestAsAccountError(t *testing.T) {
apiAccPrf := &APIAccount{
Tenant: "cgrates.org",
ID: "test_ID1",
@@ -266,7 +266,7 @@ func TestAPIBalanceAsBalance(t *testing.T) {
}
func TestAccountProfileBalancesAlteredCompareLength(t *testing.T) {
func TestAccountBalancesAlteredCompareLength(t *testing.T) {
actPrf := &Account{
Balances: map[string]*Balance{
"testString": {},
@@ -285,7 +285,7 @@ func TestAccountProfileBalancesAlteredCompareLength(t *testing.T) {
}
func TestAccountProfileBalancesAlteredCheckKeys(t *testing.T) {
func TestAccountBalancesAlteredCheckKeys(t *testing.T) {
actPrf := &Account{
Balances: map[string]*Balance{
"testString": {},
@@ -303,7 +303,7 @@ func TestAccountProfileBalancesAlteredCheckKeys(t *testing.T) {
}
func TestAccountProfileBalancesAlteredCompareValues(t *testing.T) {
func TestAccountBalancesAlteredCompareValues(t *testing.T) {
actPrf := &Account{
Balances: map[string]*Balance{
"testString": {
@@ -323,7 +323,7 @@ func TestAccountProfileBalancesAlteredCompareValues(t *testing.T) {
}
func TestAccountProfileBalancesAlteredFalse(t *testing.T) {
func TestAccountBalancesAlteredFalse(t *testing.T) {
actPrf := &Account{}
actBk := AccountBalancesBackup{}
@@ -439,8 +439,7 @@ func TestAPApsSort(t *testing.T) {
}
}
func TestAPAccountProfiles(t *testing.T) {
func TestAPAccount(t *testing.T) {
apS := AccountsWithWeight{
{
Account: &Account{
@@ -490,7 +489,7 @@ func TestAPAccountProfiles(t *testing.T) {
for i := range apS {
expected = append(expected, apS[i].Account)
}
received := apS.AccountProfiles()
received := apS.Accounts()
if !reflect.DeepEqual(received, expected) {
t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", ToJSON(expected), ToJSON(received))