From 1c11adfe376fb92a47204e3886cd66d31a5cd620 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 30 Apr 2015 19:15:05 +0200 Subject: [PATCH] Adding tests for loading ExtraParams/json in Actions.csv --- engine/loader_csv_test.go | 18 +++++++++++++++++- engine/loader_helpers_test.go | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 341f2451b..1bda36a4c 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -155,6 +155,7 @@ SE10,*topup_reset,,,*monetary,*out,,,,SG2,*unlimited,,10,5,10 SE10,*topup,,,*monetary,*out,,,,,*unlimited,,10,10,10 EE0,*topup_reset,,,*monetary,*out,,,,SG3,*unlimited,,0,10,10 EE0,*allow_negative,,,*monetary,*out,,,,,*unlimited,,0,10,10 +DEFEE,*cdrlog,"{""Category"":""^ddi"",""MediationRunId"":""^did_run""}",,,,,,,,,,,,10 ` actionTimings = ` MORE_MINUTES,MINI,ONE_TIME_RUN,10 @@ -696,7 +697,7 @@ func TestLoadRatingProfiles(t *testing.T) { } func TestLoadActions(t *testing.T) { - if len(csvr.actions) != 7 { + if len(csvr.actions) != 8 { t.Error("Failed to load actions: ", csvr.actions) } as1 := csvr.actions["MINI"] @@ -755,6 +756,21 @@ func TestLoadActions(t *testing.T) { if !reflect.DeepEqual(as2, expected) { t.Errorf("Error loading action: %+v", as2[0].Balance) } + as3 := csvr.actions["DEFEE"] + expected = []*Action{ + &Action{ + Id: "DEFEE0", + ActionType: CDRLOG, + ExtraParameters: `{"Category":"^ddi","MediationRunId":"^did_run"}`, + Weight: 10, + Balance: &Balance{ + Uuid: as3[0].Balance.Uuid, + }, + }, + } + if !reflect.DeepEqual(as3, expected) { + t.Errorf("Error loading action: %+v", as3[0]) + } } func TestLoadSharedGroups(t *testing.T) { diff --git a/engine/loader_helpers_test.go b/engine/loader_helpers_test.go index 7cf658c0a..a6caf3e12 100644 --- a/engine/loader_helpers_test.go +++ b/engine/loader_helpers_test.go @@ -69,6 +69,7 @@ LOG_BALANCE,*log,,,,,,,,,,,,,10 DUMMY,INVALID;DATA PREPAID_10,*topup_reset,,,*monetary,*out,,*any,,*unlimited,,5,10,10 TOPUP_RST_SHARED_5,*topup_reset,param&some,,*monetary,*out,,*any,subj,SHARED_A,*unlimited,,5,20,10 +DEFEE,*cdrlog,"{""Category"":""^ddi"",""MediationRunId"":""^did_run""}",,,,,,,,,,,,10 ` var actionTimingsSample = `#Tag,ActionsTag,TimingTag,Weight @@ -270,7 +271,7 @@ func TestActionsValidator(t *testing.T) { if valid { t.Error("Validation passed for invalid line", string(ln)) } - case 2, 3, 4, 7: + case 2, 3, 4, 7, 8: if !valid { t.Error("Validation did not pass for valid line", string(ln)) }