From 9d22f680f47ae1d3ba3baddae024793f856fe2fb Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 23 Jan 2018 12:09:39 +0200 Subject: [PATCH] Update test for go version 1.9.3 --- engine/attributes_test.go | 16 +++++++++++----- engine/suppliers_test.go | 10 ++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/engine/attributes_test.go b/engine/attributes_test.go index 0b5356937..91b865883 100644 --- a/engine/attributes_test.go +++ b/engine/attributes_test.go @@ -61,6 +61,12 @@ func testPopulateAttrService(t *testing.T) { Substitute: "Al1", Append: true, } + //Need clone because time.Now add extra information and DeepEqual don't like + var cloneExpTime time.Time + expTime := time.Now().Add(time.Duration(20 * time.Minute)) + if err := utils.Clone(expTime, &cloneExpTime); err != nil { + t.Error(err) + } atrPs = AttributeProfiles{ &AttributeProfile{ Tenant: "cgrates.org", @@ -69,7 +75,7 @@ func testPopulateAttrService(t *testing.T) { FilterIDs: []string{"filter1"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - ExpiryTime: time.Now().Add(time.Duration(20 * time.Minute)), + ExpiryTime: cloneExpTime, }, Attributes: attrMap, Weight: 20, @@ -81,7 +87,7 @@ func testPopulateAttrService(t *testing.T) { FilterIDs: []string{"filter2"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - ExpiryTime: time.Now().Add(time.Duration(20 * time.Minute)), + ExpiryTime: cloneExpTime, }, Attributes: attrMap, Weight: 20, @@ -151,9 +157,9 @@ func testAttributeMatchingAttributeProfilesForEvent(t *testing.T) { t.Errorf("Error: %+v", err) } if !reflect.DeepEqual(atrPs[0], atrpl[0]) && !reflect.DeepEqual(atrPs[0], atrpl[1]) { - t.Errorf("Expecting: %+v, received: %+v", atrPs[0], atrpl[0]) + t.Errorf("Expecting: %+v, received: %+v ", atrPs[0], atrpl[0]) } else if !reflect.DeepEqual(atrPs[1], atrpl[1]) && !reflect.DeepEqual(atrPs[1], atrpl[0]) { - t.Errorf("Expecting: %+v, received: %+v", atrPs[1], atrpl[1]) + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(atrPs), utils.ToJSON(atrpl)) } } @@ -174,7 +180,7 @@ func testAttributeProfileForEvent(t *testing.T) { t.Errorf("Error: %+v", err) } if !reflect.DeepEqual(atrPs[0], atrpl) && !reflect.DeepEqual(atrPs[1], atrpl) { - t.Errorf("Expecting: %+v, received: %+v", atrPs[0], atrpl) + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(atrPs[0]), utils.ToJSON(atrpl)) } } diff --git a/engine/suppliers_test.go b/engine/suppliers_test.go index 1cbd5d6e2..7020f1475 100644 --- a/engine/suppliers_test.go +++ b/engine/suppliers_test.go @@ -193,6 +193,7 @@ func TestSuppliersPopulateSupplierService(t *testing.T) { sorter: ssd, } ssd[utils.MetaLeastCost] = NewLeastCostSorter(&splserv) + argPagEv = &ArgsGetSuppliers{ CGREvent: utils.CGREvent{ Tenant: "cgrates.org", @@ -207,6 +208,11 @@ func TestSuppliersPopulateSupplierService(t *testing.T) { }, }, } + var cloneExpTime time.Time + expTime := time.Now().Add(time.Duration(20 * time.Minute)) + if err := utils.Clone(expTime, &cloneExpTime); err != nil { + t.Error(err) + } sprsmatch = SupplierProfiles{ &SupplierProfile{ Tenant: "cgrates.org", @@ -214,7 +220,7 @@ func TestSuppliersPopulateSupplierService(t *testing.T) { FilterIDs: []string{"filter3"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - ExpiryTime: time.Now().Add(time.Duration(20 * time.Minute)), + ExpiryTime: cloneExpTime, }, Sorting: utils.MetaWeight, SortingParams: []string{}, @@ -239,7 +245,7 @@ func TestSuppliersPopulateSupplierService(t *testing.T) { FilterIDs: []string{"filter4"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - ExpiryTime: time.Now().Add(time.Duration(20 * time.Minute)), + ExpiryTime: cloneExpTime, }, Sorting: utils.MetaWeight, SortingParams: []string{},