From 73451d4f1abc7060cf79cb35582759c237eede6c Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 14 Nov 2017 10:26:07 +0200 Subject: [PATCH] Add test for FilterToTPFilter --- engine/model_helpers_test.go | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 295da0f1e..20e8dbc84 100755 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -21,6 +21,7 @@ package engine import ( "reflect" "testing" + "time" "github.com/cgrates/cgrates/utils" ) @@ -1021,3 +1022,40 @@ func TestAPItoTPFilter(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", eTPs, st) } } + +func TestFilterToTPFilter(t *testing.T) { + filter := &Filter{ + Tenant: "cgrates.org", + ID: "Fltr1", + ActivationInterval: &utils.ActivationInterval{ + ActivationTime: time.Date(2014, 1, 14, 0, 0, 0, 0, time.UTC), + ExpiryTime: time.Date(2014, 1, 14, 0, 0, 0, 0, time.UTC), + }, + RequestFilters: []*RequestFilter{ + &RequestFilter{ + FieldName: "Account", + Type: "*string", + Values: []string{"1001", "1002"}, + }, + }, + } + tpfilter := &utils.TPFilter{ + ID: "Fltr1", + Tenant: "cgrates.org", + ActivationInterval: &utils.TPActivationInterval{ + ActivationTime: "2014-01-14T00:00:00Z", + ExpiryTime: "2014-01-14T00:00:00Z", + }, + Filters: []*utils.TPRequestFilter{ + &utils.TPRequestFilter{ + FieldName: "Account", + Type: "*string", + Values: []string{"1001", "1002"}, + }, + }, + } + eTPFilter := FilterToTPFilter(filter) + if !reflect.DeepEqual(tpfilter, eTPFilter) { + t.Errorf("Expecting: %+v, received: %+v", tpfilter, eTPFilter) + } +}