From 9e83b9448e5d05472479c77ed670a92d9ab76148 Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Tue, 24 Nov 2020 17:50:15 +0200 Subject: [PATCH] Moved connectFee upper in incremets intervals --- rates/librates_test.go | 82 +++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/rates/librates_test.go b/rates/librates_test.go index 7220719cc..166905a0a 100644 --- a/rates/librates_test.go +++ b/rates/librates_test.go @@ -1581,15 +1581,15 @@ func TestComputeRateSIntervals(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.10, Unit: 1 * time.Minute, Increment: 1 * time.Minute, - RecurrentFee: 0.10, }, { IntervalStart: 60 * time.Second, + RecurrentFee: 0.05, Unit: 1 * time.Minute, Increment: 1 * time.Second, - RecurrentFee: 0.05, }, }, } @@ -1599,18 +1599,16 @@ func TestComputeRateSIntervals(t *testing.T) { ID: "RATE1", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: 0, + RecurrentFee: 0.20, Unit: 1 * time.Minute, Increment: 1 * time.Second, - RecurrentFee: 0.20, }, { - IntervalStart: 2 * time.Minute, + RecurrentFee: 0.15, Unit: 1 * time.Minute, Increment: 1 * time.Second, - RecurrentFee: 0.15, }, }, } @@ -1736,15 +1734,15 @@ func TestComputeRateSIntervals1(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.20, Unit: 30 * time.Second, Increment: 30 * time.Second, - RecurrentFee: 0.20, }, { IntervalStart: 30 * time.Second, + RecurrentFee: 0.15, Unit: 1 * time.Minute, Increment: 1 * time.Second, - RecurrentFee: 0.15, }, }, } @@ -1755,15 +1753,15 @@ func TestComputeRateSIntervals1(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.20, Unit: 1 * time.Minute, Increment: 1 * time.Second, - RecurrentFee: 0.20, }, { IntervalStart: 2 * time.Minute, + RecurrentFee: 0.15, Unit: time.Minute, Increment: 1 * time.Second, - RecurrentFee: 0.15, }, }, } @@ -1944,15 +1942,15 @@ func TestComputeRateSIntervals2(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 1.00, Unit: time.Minute, Increment: time.Minute, - RecurrentFee: 1.00, }, { IntervalStart: 50 * time.Minute, + RecurrentFee: 0.50, Unit: time.Minute, Increment: time.Minute, - RecurrentFee: 0.50, }, }, } @@ -1964,15 +1962,15 @@ func TestComputeRateSIntervals2(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.15, Unit: time.Minute, Increment: time.Minute, - RecurrentFee: 0.15, }, { IntervalStart: 45 * time.Minute, + RecurrentFee: 0.20, Unit: time.Minute, Increment: time.Minute, - RecurrentFee: 0.20, }, }, } @@ -2054,21 +2052,21 @@ func TestComputeRateSIntervalsEvery30Seconds(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.10, Unit: 30 * time.Second, Increment: time.Second, - Value: 0.10, }, { IntervalStart: time.Minute, + RecurrentFee: 0.20, Unit: 30 * time.Second, Increment: time.Second, - Value: 0.20, }, { IntervalStart: 2 * time.Minute, + RecurrentFee: 0.30, Unit: 30 * time.Second, Increment: time.Second, - Value: 0.30, }, }, } @@ -2079,21 +2077,21 @@ func TestComputeRateSIntervalsEvery30Seconds(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 30 * time.Second, + RecurrentFee: 0.15, Unit: 30 * time.Second, Increment: time.Second, - Value: 0.15, }, { IntervalStart: time.Minute + 30*time.Second, + RecurrentFee: 0.25, Unit: 30 * time.Second, Increment: time.Second, - Value: 0.25, }, { IntervalStart: 2*time.Minute + 30*time.Second, + RecurrentFee: 0.35, Unit: 30 * time.Second, Increment: time.Second, - Value: 0.35, }, }, } @@ -2219,9 +2217,9 @@ func TestComputeRateSIntervalsStartHigherThanUsage(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: time.Minute, + RecurrentFee: 0.10, Unit: 30 * time.Second, Increment: 30 * time.Second, - Value: 0.10, }, }, } @@ -2232,9 +2230,9 @@ func TestComputeRateSIntervalsStartHigherThanUsage(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 2 * time.Minute, + RecurrentFee: 0.20, Unit: 30 * time.Second, Increment: 30 * time.Second, - Value: 0.20, }, }, } @@ -2258,9 +2256,9 @@ func TestComputeRateSIntervalsZeroIncrement(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.10, Unit: 30 * time.Second, Increment: 0 * time.Second, - Value: 0.10, }, }, } @@ -2285,15 +2283,15 @@ func TestComputeRateSIntervalsCeilingCmpFactor(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.10, Unit: 30 * time.Second, Increment: 1 * time.Second, - Value: 0.10, }, { IntervalStart: 30 * time.Second, + RecurrentFee: 0.25, Unit: time.Minute, Increment: 7 * time.Second, - Value: 0.25, }, }, } @@ -2340,15 +2338,15 @@ func TestComputeRateSIntervalsSwitchingRates(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.10, Unit: 30 * time.Second, Increment: 1 * time.Second, - Value: 0.10, }, { IntervalStart: 25 * time.Second, + RecurrentFee: 0.25, Unit: time.Minute, Increment: 7 * time.Second, - Value: 0.25, }, }, } @@ -2359,15 +2357,15 @@ func TestComputeRateSIntervalsSwitchingRates(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 45 * time.Second, + RecurrentFee: 0.15, Unit: 30 * time.Second, Increment: 1 * time.Second, - Value: 0.15, }, { IntervalStart: 55 * time.Second, + RecurrentFee: 0.30, Unit: 30 * time.Minute, Increment: 5 * time.Second, - Value: 0.30, }, }, } @@ -2378,15 +2376,15 @@ func TestComputeRateSIntervalsSwitchingRates(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 30 * time.Second, + RecurrentFee: 0.10, Unit: 25 * time.Second, Increment: 5 * time.Second, - Value: 0.10, }, { IntervalStart: time.Minute, + RecurrentFee: 0.05, Unit: 10 * time.Second, Increment: 5 * time.Second, - Value: 0.05, }, }, } @@ -2493,15 +2491,15 @@ func TestComputeRatesIntervalsAllInOne(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: time.Minute, + RecurrentFee: 0.30, Unit: 30 * time.Second, Increment: 1 * time.Second, - Value: 0.30, }, { IntervalStart: 3 * time.Minute, + RecurrentFee: 0.30, Unit: time.Minute, Increment: 7 * time.Second, - Value: 0.30, }, }, } @@ -2512,15 +2510,15 @@ func TestComputeRatesIntervalsAllInOne(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: time.Minute + 30*time.Second, + RecurrentFee: 0.20, Unit: 30 * time.Second, Increment: 1 * time.Second, - Value: 0.20, }, { IntervalStart: 2*time.Minute + 30*time.Second, + RecurrentFee: 0.20, Unit: 30 * time.Second, Increment: 7 * time.Second, - Value: 0.20, }, }, } @@ -2531,9 +2529,9 @@ func TestComputeRatesIntervalsAllInOne(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 2 * time.Minute, + RecurrentFee: 0.10, Unit: 30 * time.Second, Increment: 30 * time.Second, - Value: 0.10, }, }, } @@ -2646,15 +2644,15 @@ func TestOrderRatesIntervalsFullDay(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 0, + RecurrentFee: 0.50, Unit: time.Hour, Increment: 3 * time.Minute, - Value: 0.50, }, { IntervalStart: 4 * time.Hour, + RecurrentFee: 0.35, Unit: time.Hour, Increment: 3 * time.Minute, - Value: 0.35, }, }, } @@ -2665,15 +2663,15 @@ func TestOrderRatesIntervalsFullDay(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 13 * time.Hour, + RecurrentFee: 0.40, Unit: time.Hour, Increment: 3 * time.Minute, - Value: 0.40, }, { IntervalStart: 16 * time.Hour, + RecurrentFee: 0.35, Unit: time.Hour, Increment: 3 * time.Minute, - Value: 0.35, }, }, } @@ -2684,15 +2682,15 @@ func TestOrderRatesIntervalsFullDay(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { IntervalStart: 12 * time.Hour, + RecurrentFee: 0.20, Unit: 30 * time.Hour, Increment: 2 * time.Minute, - Value: 0.20, }, { IntervalStart: 12*time.Hour + 30*time.Minute, + RecurrentFee: 0.10, Unit: time.Hour, Increment: 5 * time.Minute, - Value: 0.10, }, }, }