From c04f79b9b08f2264c51f595226d6c0ded0c0c093 Mon Sep 17 00:00:00 2001 From: DanB Date: Fri, 16 Dec 2016 20:11:49 +0100 Subject: [PATCH] Sample Balance factor in loader_csv --- engine/loader_csv_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 378d457d9..0b5fce18e 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -184,6 +184,7 @@ FILTER,*topup,,"{""*and"":[{""Value"":{""*lt"":0}},{""Id"":{""*eq"":""*default"" EXP,*topup,,,,*voice,*out,,,,,*monthly,*any,300,10,false,false,10 NOEXP,*topup,,,,*voice,*out,,,,,*unlimited,*any,50,10,false,false,10 VF,*debit,,,,*monetary,*out,,,,,*unlimited,*any,"{""Method"":""*incremental"",""Params"":{""Units"":10, ""Interval"":""month"", ""Increment"":""day""}}",10,false,false,10 +TOPUP_RST_GNR_1000,*topup_reset,"{""*voice"": 60.0,""*data"":1024.0,""*sms"":1.0}",,,*generic,*out,,*any,,,*unlimited,,1000,20,false,false,10 ` actionPlans = ` MORE_MINUTES,MINI,ONE_TIME_RUN,10 @@ -850,7 +851,7 @@ func TestLoadRatingProfiles(t *testing.T) { } func TestLoadActions(t *testing.T) { - if len(csvr.actions) != 15 { + if len(csvr.actions) != 16 { t.Error("Failed to load actions: ", len(csvr.actions)) } as1 := csvr.actions["MINI"] @@ -947,6 +948,30 @@ func TestLoadActions(t *testing.T) { if !reflect.DeepEqual(as3, expected) { t.Errorf("Error loading action: %+v", as3[0].Balance) } + asGnrc := csvr.actions["TOPUP_RST_GNR_1000"] + //TOPUP_RST_GNR_1000,*topup_reset,"{""*voice"": 60.0,""*data"":1024.0,""*sms"":1.0}",,,*generic,*out,,*any,,,*unlimited,,1000,20,false,false,10 + expected = []*Action{ + &Action{ + Id: "TOPUP_RST_GNR_1000", + ActionType: TOPUP_RESET, + ExtraParameters: `{"*voice": 60.0,"*data":1024.0,"*sms":1.0}`, + Weight: 10, + ExpirationString: utils.UNLIMITED, + Balance: &BalanceFilter{ + Uuid: asGnrc[0].Balance.Uuid, + Type: utils.StringPointer(utils.GENERIC), + Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT)), + //DestinationIDs: utils.StringMapPointer(utils.NewStringMap("*any")), + Value: &utils.ValueFormula{Static: 1000}, + Weight: utils.Float64Pointer(20), + Disabled: utils.BoolPointer(false), + Blocker: utils.BoolPointer(false), + }, + }, + } + if !reflect.DeepEqual(asGnrc, expected) { + t.Errorf("Expecting: %+v, received: %+v", expected[0].Balance, asGnrc[0].Balance) + } } func TestLoadSharedGroups(t *testing.T) {