test: Add critical-only grouped alert template case
Test multiple critical alerts without warnings to cover the "critical > 0" only branch in subject line generation. Coverage: 97.7% → 100%
This commit is contained in:
parent
96bf0b0ca6
commit
44b835ad15
1 changed files with 26 additions and 0 deletions
|
|
@ -606,6 +606,32 @@ func TestEmailTemplate(t *testing.T) {
|
|||
expectSingleSubject: true,
|
||||
subjectContains: "Warning",
|
||||
},
|
||||
{
|
||||
name: "multiple critical alerts only uses grouped template",
|
||||
alerts: []*alerts.Alert{
|
||||
{
|
||||
ID: "alert-1",
|
||||
Level: "critical",
|
||||
Type: "cpu",
|
||||
ResourceName: "vm-1",
|
||||
Value: 95.5,
|
||||
Threshold: 90.0,
|
||||
StartTime: time.Now(),
|
||||
},
|
||||
{
|
||||
ID: "alert-2",
|
||||
Level: "critical",
|
||||
Type: "memory",
|
||||
ResourceName: "vm-2",
|
||||
Value: 98.0,
|
||||
Threshold: 90.0,
|
||||
StartTime: time.Now(),
|
||||
},
|
||||
},
|
||||
isSingle: false,
|
||||
expectSingleSubject: false,
|
||||
subjectContains: "2 Critical alerts",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
Loading…
Reference in a new issue