Add unit test case for func HasAlertingRules in manager.go (#7502)
Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
This commit is contained in:
parent
f32307b656
commit
ad9449d1f1
|
@ -1118,3 +1118,42 @@ func countStaleNaN(t *testing.T, st storage.Storage) int {
|
|||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func TestGroupHasAlertingRules(t *testing.T) {
|
||||
tests := []struct {
|
||||
group *Group
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
group: &Group{
|
||||
name: "HasAlertingRule",
|
||||
rules: []Rule{
|
||||
NewAlertingRule("alert", nil, 0, nil, nil, nil, true, nil),
|
||||
NewRecordingRule("record", nil, nil),
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
group: &Group{
|
||||
name: "HasNoRule",
|
||||
rules: []Rule{},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
group: &Group{
|
||||
name: "HasOnlyRecordingRule",
|
||||
rules: []Rule{
|
||||
NewRecordingRule("record", nil, nil),
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
got := test.group.HasAlertingRules()
|
||||
testutil.Assert(t, test.want == got, "test case %d failed, expected:%t got:%t", i, test.want, got)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue