Added tests to statmetrics

This commit is contained in:
andronache
2021-01-11 16:29:46 +02:00
committed by Dan Christian Bogos
parent 9d8bc0f7c6
commit 64e65d70d2

View File

@@ -3222,3 +3222,43 @@ func TestStatMetricsStatDistinctRemEvent(t *testing.T) {
t.Errorf("\nExpecting <%+v>,\n Recevied <%+v>", expected, dst)
}
}
func TestStatMetricsStatDistinctRemEvent2(t *testing.T) {
dst := StatDistinct{
FilterIDs: []string{"Test_Filter_ID"},
FieldValues: map[string]utils.StringSet{
"FieldValue1": {},
},
Events: map[string]map[string]int64{
"Event1": {
"FieldValue1": 2,
},
"Event2": {},
},
MinItems: 3,
FieldName: "Test_Field_Name",
Count: 3,
}
expected := StatDistinct{
FilterIDs: []string{"Test_Filter_ID"},
FieldValues: map[string]utils.StringSet{
"FieldValue1": {},
},
Events: map[string]map[string]int64{
"Event1": {
"FieldValue1": 1,
},
"Event2": {},
},
MinItems: 3,
FieldName: "Test_Field_Name",
Count: 2,
}
err := dst.RemEvent("Event1")
if err != nil {
t.Errorf("\nExpecting <nil>,\n Recevied <%+v>", err)
}
if !reflect.DeepEqual(expected, dst) {
t.Errorf("\nExpecting <%+v>,\n Recevied <%+v>", expected, dst)
}
}