Add coverage tests for engine

This commit is contained in:
NikolasPetriti
2023-08-15 16:59:56 +02:00
committed by Dan Christian Bogos
parent af3d585d72
commit 5ef01e6f0b
7 changed files with 454 additions and 1 deletions

View File

@@ -667,4 +667,4 @@ func TestBalanceCloneNil(t *testing.T) {
if rcv != nil {
t.Error(rcv)
}
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}