From 8e3bf6e945ff13350dbbd10b10812b0ceb3d0bdc Mon Sep 17 00:00:00 2001 From: TeoV Date: Mon, 21 Dec 2020 15:17:11 +0200 Subject: [PATCH] Add unit test in loader_csv_test for AccountProfile --- dispatchers/attributes.go | 2 +- engine/libtest.go | 2 ++ engine/loader_csv_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/dispatchers/attributes.go b/dispatchers/attributes.go index bf49d162e..36449ebbd 100755 --- a/dispatchers/attributes.go +++ b/dispatchers/attributes.go @@ -23,7 +23,7 @@ import ( "github.com/cgrates/cgrates/utils" ) -// AttributeSv1Ping interogates AttributeS server responsible to process the event +// AttributeSv1Ping interrogates AttributeS server responsible to process the event func (dS *DispatcherService) AttributeSv1Ping(args *utils.CGREventWithOpts, reply *string) (err error) { if args == nil { diff --git a/engine/libtest.go b/engine/libtest.go index c05edea28..b3359e675 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -299,6 +299,8 @@ cgrates.org,ONE_TIME_ACT,,,,,,,TOPUP_TEST_VOICE,,false,0s,*topup,,~*balance.Test AccountProfileCSVContent = ` #Tenant,ID,FilterIDs,ActivationInterval,Weight,BalanceID,BalanceFilterIDs,BalanceWeight,BalanceBlocker,BalanceType,BalanceOpts,BalanceValue +cgrates.org,1001,,,20,MonetaryBalance,,10,,*monetary,,14 +cgrates.org,1001,,,,VoiceBalance,,10,,*voice,,3600000000000 ` ) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 95f1b0fd8..c8369a2e3 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -1625,3 +1625,41 @@ func TestLoadThresholds(t *testing.T) { t.Errorf("Failed to load thresholds: %s", utils.ToIJSON(csvr.thresholds)) } } + +func TestLoadAccountProfiles(t *testing.T) { + expected := &utils.TPAccountProfile{ + TPid: testTPID, + Tenant: "cgrates.org", + ID: "1001", + Weight: 20, + Balances: []*utils.TPAccountBalance{ + &utils.TPAccountBalance{ + ID: "MonetaryBalance", + FilterIDs: []string{}, + Weight: 10, + Type: utils.MONETARY, + Value: 14, + }, + &utils.TPAccountBalance{ + ID: "VoiceBalance", + FilterIDs: []string{}, + Weight: 10, + Type: utils.VOICE, + Value: 3600000000000, + }, + }, + } + + if len(csvr.accountProfiles) != 1 { + t.Fatalf("Failed to load ActionProfiles: %s", utils.ToJSON(csvr.actionProfiles)) + } + accPrfKey := utils.TenantID{ + Tenant: "cgrates.org", + ID: "1001", + } + + if !reflect.DeepEqual(csvr.accountProfiles[accPrfKey], expected) { + t.Errorf("Expecting: %+v,\n received: %+v", + utils.ToJSON(expected), utils.ToJSON(csvr.accountProfiles[accPrfKey])) + } +}