diff --git a/engine/balances_test.go b/engine/balances_test.go index c27492873..d2d795ab7 100644 --- a/engine/balances_test.go +++ b/engine/balances_test.go @@ -667,4 +667,4 @@ func TestBalanceCloneNil(t *testing.T) { if rcv != nil { t.Error(rcv) } -} +} \ No newline at end of file diff --git a/engine/callcost_test.go b/engine/callcost_test.go index ed8960031..69e385ec5 100644 --- a/engine/callcost_test.go +++ b/engine/callcost_test.go @@ -317,3 +317,13 @@ func TestCallCostUpdateCost(t *testing.T) { t.Error("didn't update") } } + +func TestCallCostUpdateRatedUsage(t *testing.T) { + var cc *CallCost + + rcv := cc.UpdateRatedUsage() + + if rcv != 0 { + t.Error(rcv) + } +} \ No newline at end of file diff --git a/engine/cdr_test.go b/engine/cdr_test.go index d014f489b..12ec84966 100644 --- a/engine/cdr_test.go +++ b/engine/cdr_test.go @@ -1627,3 +1627,13 @@ func TestMetaHandler(t *testing.T) { }) } } + +func TestCDRCloneNil(t *testing.T) { + var cdr *CDR + + rcv := cdr.Clone() + + if rcv != nil { + t.Error(rcv) + } +} \ No newline at end of file diff --git a/engine/destinations_test.go b/engine/destinations_test.go index 125138768..18f715709 100644 --- a/engine/destinations_test.go +++ b/engine/destinations_test.go @@ -175,3 +175,13 @@ func BenchmarkDestinationStorageStoreRestore(b *testing.B) { dm.GetDestination(nationale.Id, true, utils.NonTransactional) } } + +func TestDestinationcontainsPrefixNil(t *testing.T) { + var d *Destination + + rcv := d.containsPrefix("test") + + if rcv != 0 { + t.Error(rcv) + } +} diff --git a/engine/libeventcost_test.go b/engine/libeventcost_test.go index 2feb1a207..9dbf0139c 100644 --- a/engine/libeventcost_test.go +++ b/engine/libeventcost_test.go @@ -1745,3 +1745,13 @@ func TestLibeventcostIfaceAsEventCost(t *testing.T) { }) } } + +func TestLibEventCostClone(t *testing.T) { + var rf RatingMatchedFilters + + rcv := rf.Clone() + + if rcv != nil { + t.Error(rcv) + } +} diff --git a/engine/ratingplan_test.go b/engine/ratingplan_test.go index f74647920..00498dddc 100644 --- a/engine/ratingplan_test.go +++ b/engine/ratingplan_test.go @@ -451,3 +451,89 @@ func BenchmarkRatingPlanRestore(b *testing.B) { dm.GetRatingPlan(rp.Id, true, utils.NonTransactional) } } + +func TestRatingPlanEqual(t *testing.T) { + rt := &RITiming{ + Years: utils.Years{}, + Months: utils.Months{}, + MonthDays: utils.MonthDays{}, + WeekDays: utils.WeekDays{}, + StartTime: "00:00:00", + EndTime: "00:00:00", + cronString: str, + tag: str, + } + + rr := &RIRate{ + ConnectFee: fl, + RoundingMethod: str, + RoundingDecimals: nm, + MaxCost: fl, + MaxCostStrategy: str, + Rates: RateGroups{{ + GroupIntervalStart: 1 * time.Second, + Value: fl, + RateIncrement: 1 * time.Second, + RateUnit: 1 * time.Second, + }}, + tag: str, + } + + rl := RPRateList{{ + Timing: str, + Rating: str, + Weight: fl, + }} + + rp := &RatingPlan{ + Id: "test", + Timings: map[string]*RITiming{str: rt}, + Ratings: map[string]*RIRate{str: rr}, + DestinationRates: map[string]RPRateList{str: rl}, + } + + rt2 := &RITiming{ + Years: utils.Years{}, + Months: utils.Months{}, + MonthDays: utils.MonthDays{}, + WeekDays: utils.WeekDays{}, + StartTime: "00:00:00", + EndTime: "00:00:00", + cronString: "val1", + tag: str, + } + + rr2 := &RIRate{ + ConnectFee: 3.6, + RoundingMethod: str, + RoundingDecimals: nm, + MaxCost: fl, + MaxCostStrategy: str, + Rates: RateGroups{{ + GroupIntervalStart: 1 * time.Second, + Value: fl, + RateIncrement: 1 * time.Second, + RateUnit: 1 * time.Second, + }}, + tag: str, + } + + rl2 := RPRateList{{ + Timing: "test2", + Rating: str, + Weight: 1.0, + }} + + o := &RatingPlan{ + Id: "test2", + Timings: map[string]*RITiming{str: rt2}, + Ratings: map[string]*RIRate{str: rr2}, + DestinationRates: map[string]RPRateList{str: rl2}, + } + + rcv := rp.Equal(o) + + if rcv != false { + t.Error(rcv) + } +} \ No newline at end of file diff --git a/engine/statmetrics_test.go b/engine/statmetrics_test.go index c3e448861..1dc5517c3 100644 --- a/engine/statmetrics_test.go +++ b/engine/statmetrics_test.go @@ -3051,3 +3051,330 @@ func TestStatDistrictMarshal(t *testing.T) { t.Errorf("Expected: %s , received: %s", utils.ToJSON(statDistinct), utils.ToJSON(nStatDistinct)) } } + +func TestStatMetricsGetFilterIDs(t *testing.T) { + slc := []string{"test"} + tm := 1 * time.Second + acd := &StatACD{ + FilterIDs: slc, + Sum: 1 * time.Second, + Count: 1, + Events: map[string]*DurationWithCompress{ + str: { + Duration: 1 * time.Second, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &tm, + } + + exp := slc + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(exp, rcv) { + t.Errorf("expected %v, received %v", exp, rcv) + } +} + +func TestStatMetricsGetFilterIDsStatTCD(t *testing.T) { + slc := []string{"test"} + tm := 1 * time.Second + acd := &StatTCD{ + FilterIDs: slc, + Sum: 1 * time.Second, + Count: 1, + Events: map[string]*DurationWithCompress{ + str: { + Duration: 1 * time.Second, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &tm, + } + + exp := slc + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(exp, rcv) { + t.Errorf("expected %v, received %v", exp, rcv) + } +} + +func TestStatMetricsGetFloat64ValueStatACC(t *testing.T) { + fl := 1.2 + slc := []string{"test"} + acd := &StatACC{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + exp := fl + rcv := acd.GetFloat64Value() + + if !reflect.DeepEqual(exp, rcv) { + t.Errorf("expected %v, received %v", exp, rcv) + } +} + +func TestStatMetricsGetFilterIDsStatACC(t *testing.T) { + fl := 1.2 + slc := []string{"test"} + acd := &StatACC{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + exp := slc + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(exp, rcv) { + t.Errorf("expected %v, received %v", exp, rcv) + } +} + +func TestStatMetricsGetFloat64ValueStatTCC(t *testing.T) { + fl := 1.2 + slc := []string{"test"} + acd := &StatTCC{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + exp := fl + rcv := acd.GetFloat64Value() + + if !reflect.DeepEqual(exp, rcv) { + t.Errorf("expected %v, received %v", exp, rcv) + } +} + +func TestStatMetricsGetFilterIDsStatTCC(t *testing.T) { + fl := 1.2 + slc := []string{"test"} + acd := &StatTCC{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + exp := slc + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(exp, rcv) { + t.Errorf("expected %v, received %v", exp, rcv) + } +} + +func TestStatMetricsGetFilterIDsStatPDD(t *testing.T) { + tm := 1 * time.Second + slc := []string{"test"} + acd := &StatPDD{ + FilterIDs: slc, + Sum: 1 * time.Second, + Count: 1, + Events: map[string]*DurationWithCompress{ + str: { + Duration: 1 * time.Second, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &tm, + } + + exp := slc + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(exp, rcv) { + t.Errorf("expected %v, received %v", exp, rcv) + } +} + +func TestStatMetricsGetFilterIDsStatDDC(t *testing.T) { + slc := []string{"test"} + acd := &StatDDC{ + FilterIDs: slc, + MinItems: 1, + Count: 1, + } + + rcv := acd.GetValue() + + if rcv != 0. { + t.Errorf("expected %v, received %v", 0., rcv) + } +} + +func TestStatMetricsGetFilterIDsDDC(t *testing.T) { + slc := []string{"test"} + acd := &StatDDC{ + FilterIDs: slc, + MinItems: 1, + Count: 1, + } + + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(slc, rcv) { + t.Errorf("expected %v, received %v", slc, rcv) + } +} + +func TestStatMetricsGetValueSum(t *testing.T) { + slc := []string{"test"} + acd := &StatSum{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + rcv := acd.GetValue() + + if rcv != fl { + t.Errorf("expected %v, received %v", fl, rcv) + } +} + +func TestStatMetricsGetFilterIDsSum(t *testing.T) { + slc := []string{"test"} + acd := &StatSum{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(slc, rcv) { + t.Errorf("expected %v, received %v", slc, rcv) + } +} + +func TestStatMetricsGetValueAvarage(t *testing.T) { + slc := []string{"test"} + acd := &StatAverage{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + rcv := acd.GetValue() + + if rcv != fl { + t.Errorf("expected %v, received %v", fl, rcv) + } +} + +func TestStatMetricsGetFilterIDsAvarage(t *testing.T) { + slc := []string{"test"} + acd := &StatAverage{ + FilterIDs: slc, + Sum: 1.2, + Count: 1, + Events: map[string]*StatWithCompress{ + "test": { + Stat: fl, + CompressFactor: 1, + }, + }, + MinItems: 1, + val: &fl, + } + + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(slc, rcv) { + t.Errorf("expected %v, received %v", slc, rcv) + } +} + +func TestStatMetricsGetValueDistinct(t *testing.T) { + slc := []string{"test"} + acd := &StatDistinct{ + FilterIDs: slc, + MinItems: 1, + Count: 1, + } + + rcv := acd.GetValue() + + if rcv != 0. { + t.Errorf("expected %v, received %v", 0., rcv) + } +} + +func TestStatMetricsGetFilterIDsDistinct(t *testing.T) { + slc := []string{"test"} + acd := &StatDistinct{ + FilterIDs: slc, + MinItems: 1, + Count: 1, + } + + rcv := acd.GetFilterIDs() + + if !reflect.DeepEqual(slc, rcv) { + t.Errorf("expected %v, received %v", slc, rcv) + } +}