From 364f74c6c8298997615d67a8427dfd6e211b2df9 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Thu, 21 May 2015 16:38:22 +0300 Subject: [PATCH] more validations and tests --- engine/ratingplan.go | 3 +++ engine/ratingplan_test.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/engine/ratingplan.go b/engine/ratingplan.go index c0606e347..2ec961205 100644 --- a/engine/ratingplan.go +++ b/engine/ratingplan.go @@ -160,6 +160,9 @@ func (rp *RatingPlan) areRatesSane() bool { if math.Mod(nextRate.GroupIntervalStart.Seconds(), rate.RateIncrement.Seconds()) != 0 { return false } + if rate.RateUnit == 0 || rate.RateIncrement == 0 { + return false + } } } } diff --git a/engine/ratingplan_test.go b/engine/ratingplan_test.go index 6286a1c52..21ec37a98 100644 --- a/engine/ratingplan_test.go +++ b/engine/ratingplan_test.go @@ -380,10 +380,12 @@ func TestRatingPlanSaneRatingsGoot(t *testing.T) { &Rate{ GroupIntervalStart: 60 * time.Second, RateIncrement: 30 * time.Second, + RateUnit: 1 * time.Second, }, &Rate{ GroupIntervalStart: 0 * time.Second, RateIncrement: 30 * time.Second, + RateUnit: 1 * time.Second, }, }, },