From 66ed3cce901d8970db8b427e7ba1395f9974813c Mon Sep 17 00:00:00 2001 From: andronache Date: Thu, 3 Dec 2020 18:03:03 +0200 Subject: [PATCH] More tests in model_helpers.go --- engine/model_helpers_test.go | 42 +++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index e0b4294a9..534970e7a 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -5266,6 +5266,46 @@ func TestAPItoModelTPDispatcherProfileCase2(t *testing.T) { } result := APItoModelTPDispatcherProfile(structTest) if !reflect.DeepEqual(result, expStruct) { - t.Errorf("\nExpecting <%T>,\n Received <%T>", expStruct, result) + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result)) + } +} + +func TestStatMdlsCSVHeader(t *testing.T) { + testStruct := ResourceMdls{ + { + Tpid: "TEST_TPID", + Tenant: "cgrates.org", + ID: "ResGroup1", + FilterIDs: "FLTR_RES_GR1", + ActivationInterval: "2014-07-29T15:00:00Z", + Stored: false, + Blocker: false, + Weight: 10.0, + Limit: "45", + ThresholdIDs: "WARN_RES1;WARN_RES1", + }, + } + expStruct := []string{"#" + utils.Tenant, utils.ID, utils.FilterIDs, utils.ActivationIntervalString, + utils.UsageTTL, utils.Limit, utils.AllocationMessage, utils.Blocker, utils.Stored, + utils.Weight, utils.ThresholdIDs} + result := testStruct.CSVHeader() + if !reflect.DeepEqual(result, expStruct) { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result)) + } +} + +func TestThresholdMdlsCSVHeader(t *testing.T) { + testStruct := ThresholdMdls{ + { + Tpid: "test_tpid", + Tenant: "test_tenant", + }, + } + expStruct := []string{"#" + utils.Tenant, utils.ID, utils.FilterIDs, utils.ActivationIntervalString, + utils.MaxHits, utils.MinHits, utils.MinSleep, + utils.Blocker, utils.Weight, utils.ActionIDs, utils.Async} + result := testStruct.CSVHeader() + if !reflect.DeepEqual(result, expStruct) { + t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result)) } }