test: Add CancelByAlertIDs empty input and no-match tests
Test early return for empty alertIDs and happy path with empty queue. Coverage: 62.9% → 65.7%
This commit is contained in:
parent
7a1c9ff53f
commit
ca7da7c18f
1 changed files with 35 additions and 0 deletions
|
|
@ -201,3 +201,38 @@ func TestQueuedNotification_ZeroValues(t *testing.T) {
|
|||
t.Error("CompletedAt should be nil by default")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCancelByAlertIDs_EmptyInput(t *testing.T) {
|
||||
// Create a temporary queue for testing
|
||||
tempDir := t.TempDir()
|
||||
nq, err := NewNotificationQueue(tempDir)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create notification queue: %v", err)
|
||||
}
|
||||
|
||||
// Empty slice should return nil without error
|
||||
err = nq.CancelByAlertIDs([]string{})
|
||||
if err != nil {
|
||||
t.Errorf("CancelByAlertIDs with empty slice returned error: %v", err)
|
||||
}
|
||||
|
||||
// Nil slice should also return nil without error
|
||||
err = nq.CancelByAlertIDs(nil)
|
||||
if err != nil {
|
||||
t.Errorf("CancelByAlertIDs with nil slice returned error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCancelByAlertIDs_NoMatchingNotifications(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
nq, err := NewNotificationQueue(tempDir)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create notification queue: %v", err)
|
||||
}
|
||||
|
||||
// With an empty queue, no notifications should match
|
||||
err = nq.CancelByAlertIDs([]string{"alert-1", "alert-2"})
|
||||
if err != nil {
|
||||
t.Errorf("CancelByAlertIDs with no matching notifications returned error: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue