From 3c77104d879fff4e72c0c353197ca99b36216fdb Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 1 Jul 2020 11:28:21 +0300 Subject: [PATCH] Reactive tests in model helpers --- engine/model_helpers_test.go | 128 ++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 60bad8528..2710fc339 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -2988,60 +2988,62 @@ func TestAPItoModelTPRateProfile(t *testing.T) { } } -/* func TestAsTPRateProfile(t *testing.T) { rtMdl := RateProfileMdls{ &RateProfileMdl{ - PK: 0, - Tpid: "", - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: "*string:~*req.Subject:1001", - ActivationInterval: "", - Weight: 0, - ConnectFee: 0.1, - RoundingMethod: "*up", - RoundingDecimals: 4, - MinCost: 0.1, - MaxCost: 0.6, - MaxCostStrategy: "*free", - RateID: "FIRST_GI", - RateFilterIDs: "*gi:~*req.Usage:0", - RateActivationInterval: "", - RateWeight: 0, - RateValue: 0.06, - RateUnit: "1m0s", - RateIncrement: "1m0s", - RateBlocker: false, - CreatedAt: time.Time{}, + PK: 0, + Tpid: "", + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: "*string:~*req.Subject:1001", + ActivationInterval: "", + Weight: 0, + ConnectFee: 0.1, + RoundingMethod: "*up", + RoundingDecimals: 4, + MinCost: 0.1, + MaxCost: 0.6, + MaxCostStrategy: "*free", + RateID: "RT_WEEK", + RateFilterIDs: "", + RateActivationStart: "* * * * 1-5", + RateWeight: 0, + RateBlocker: false, + RateIntervalStart: "1m", + RateValue: 0.06, + RateUnit: "1m", + RateIncrement: "1s", + CreatedAt: time.Time{}, }, &RateProfileMdl{ - PK: 0, - Tpid: "", - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: "", - ActivationInterval: "", - Weight: 0, - ConnectFee: 0, - RoundingMethod: "", - RoundingDecimals: 0, - MinCost: 0, - MaxCost: 0, - MaxCostStrategy: "", - RateID: "SECOND_GI", - RateFilterIDs: "*gi:~*req.Usage:1m", - RateActivationInterval: "", - RateWeight: 10, - RateValue: 0.12, - RateUnit: "1m0s", - RateIncrement: "1s", - RateBlocker: false, - CreatedAt: time.Time{}, + PK: 0, + Tpid: "", + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: "", + ActivationInterval: "", + Weight: 0, + ConnectFee: 0, + RoundingMethod: "", + RoundingDecimals: 0, + MinCost: 0, + MaxCost: 0, + MaxCostStrategy: "", + RateID: "RT_WEEK", + RateFilterIDs: "", + RateActivationStart: "", + RateWeight: 0, + RateBlocker: false, + RateIntervalStart: "0s", + RateValue: 0.12, + RateUnit: "1m", + RateIncrement: "1m", + CreatedAt: time.Time{}, }, } eRprf := &utils.TPRateProfile{ + TPid: "", Tenant: "cgrates.org", ID: "RP1", FilterIDs: []string{"*string:~*req.Subject:1001"}, @@ -3053,23 +3055,24 @@ func TestAsTPRateProfile(t *testing.T) { MaxCost: 0.6, MaxCostStrategy: "*free", Rates: map[string]*utils.TPRate{ - "FIRST_GI": { - ID: "FIRST_GI", - FilterIDs: []string{"*gi:~*req.Usage:0"}, - Weight: 0, - Value: 0.06, - Unit: "1m0s", - Increment: "1m0s", - Blocker: false, - }, - "SECOND_GI": { - ID: "SECOND_GI", - FilterIDs: []string{"*gi:~*req.Usage:1m"}, - Weight: 10, - Value: 0.12, - Unit: "1m0s", - Increment: "1s", - Blocker: false, + "RT_WEEK": &utils.TPRate{ + ID: "RT_WEEK", + Weight: 0, + ActivationStart: "* * * * 1-5", + IntervalRates: []*utils.TPIntervalRate{ + &utils.TPIntervalRate{ + IntervalStart: "1m", + Value: 0.06, + Unit: "1m", + Increment: "1s", + }, + &utils.TPIntervalRate{ + IntervalStart: "0s", + Value: 0.12, + Unit: "1m", + Increment: "1m", + }, + }, }, }, } @@ -3080,4 +3083,3 @@ func TestAsTPRateProfile(t *testing.T) { t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eRprf), utils.ToJSON(rcv[0])) } } -*/