From 44b835ad15e83e42b1ac52cfd5e90fb8216ae3c5 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 2 Dec 2025 00:40:02 +0000 Subject: [PATCH] test: Add critical-only grouped alert template case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test multiple critical alerts without warnings to cover the "critical > 0" only branch in subject line generation. Coverage: 97.7% → 100% --- internal/notifications/email_template_test.go | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/notifications/email_template_test.go b/internal/notifications/email_template_test.go index 219d667..1dab690 100644 --- a/internal/notifications/email_template_test.go +++ b/internal/notifications/email_template_test.go @@ -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 {