From cbaeb9262664364e8fb03f637c78f2264e788e69 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Tue, 12 Apr 2016 19:48:01 +0300 Subject: [PATCH] dc exclude destination test --- engine/handler_derivedcharging_test.go | 18 ++++++++++++++++++ engine/history_test.go | 1 + engine/loader_csv_test.go | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/engine/handler_derivedcharging_test.go b/engine/handler_derivedcharging_test.go index 8a2c98f54..bb793b9ba 100644 --- a/engine/handler_derivedcharging_test.go +++ b/engine/handler_derivedcharging_test.go @@ -119,3 +119,21 @@ func TestHandleDeivedChargersMatchDestNatRet(t *testing.T) { t.Error("Derived charger failed to match dest") } } + +func TestHandleDeivedChargersMatchDestSpec(t *testing.T) { + dcs := &utils.DerivedChargers{ + DestinationIDs: utils.NewStringMap("NAT", "SPEC"), + } + if !DerivedChargersMatchesDest(dcs, "0723045326") { + t.Error("Derived charger failed to match dest") + } +} + +func TestHandleDeivedChargersMatchDestNegativeSpec(t *testing.T) { + dcs := &utils.DerivedChargers{ + DestinationIDs: utils.NewStringMap("NAT", "!SPEC"), + } + if DerivedChargersMatchesDest(dcs, "0723045326") { + t.Error("Derived charger failed to match dest") + } +} diff --git a/engine/history_test.go b/engine/history_test.go index 3e51c5a4a..e3d797e4b 100644 --- a/engine/history_test.go +++ b/engine/history_test.go @@ -47,6 +47,7 @@ func TestHistoryDestinations(t *testing.T) { {"Id":"PSTN_71","Prefixes":["+4971"]}, {"Id":"PSTN_72","Prefixes":["+4972"]}, {"Id":"RET","Prefixes":["0723","0724"]}, +{"Id":"SPEC","Prefixes":["0723045"]}, {"Id":"URG","Prefixes":["112"]}` if !strings.Contains(buf.String(), expected) { t.Error("Error in destination history content:", buf.String()) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 357f56fb8..d26ebbcc6 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -42,6 +42,7 @@ NAT,0723 NAT,+49 RET,0723 RET,0724 +SPEC,0723045 PSTN_71,+4971 PSTN_72,+4972 PSTN_70,+4970 @@ -319,7 +320,7 @@ func init() { } func TestLoadDestinations(t *testing.T) { - if len(csvr.destinations) != 12 { + if len(csvr.destinations) != 13 { t.Error("Failed to load destinations: ", len(csvr.destinations)) } for _, d := range csvr.destinations {