Commit graph

11 commits

Author SHA1 Message Date
rcourtman
e46239d8ac Preserve queued recovery notifications on alert cancellation (#1350) 2026-03-25 13:18:33 +00:00
rcourtman
a3fcaafbdb test(notifications): remove queue stats race with background processor 2026-03-03 21:37:27 +00:00
rcourtman
629645a2a0 test: Add UpdateStatus not found test for notifications package 2025-12-02 14:26:17 +00:00
rcourtman
89b624c731 test: Add NewNotificationQueue invalid path test for notifications package 2025-12-02 14:17:05 +00:00
rcourtman
d5acf4be32 test: Add performCleanup tests for notifications queue
Add 4 tests covering the performCleanup function:
- cleanup removes old completed entries (>7 days)
- cleanup removes old DLQ entries (>30 days)
- cleanup removes old audit logs (>30 days)
- cleanup with empty database (no panic)

performCleanup coverage: 0% → 87.0%
Notifications package: 57.3% → 58.3%
2025-12-02 12:16:55 +00:00
rcourtman
3427aa7f01 fix: Deadlock in CancelByAlertIDs and add tests
Fixed deadlock where CancelByAlertIDs held nq.mu.Lock() and then called
UpdateStatus() which also tried to acquire the same lock. Now uses
direct SQL while holding the lock.

Tests added for CancelByAlertIDs:
- No matching notifications (notification stays pending)
- Matching notification cancelled
- Multiple alerts with partial match (any match cancels)

Coverage: CancelByAlertIDs 65.7% -> 81.1%
2025-12-02 10:40:07 +00:00
rcourtman
3000c3be87 test: Add queue IncrementAttempt and GetQueueStats tests
Coverage improvements:
- IncrementAttempt: 0% -> 85.7%
- GetQueueStats: 0% -> 87.5%

Tests verify attempt counter increments correctly and queue stats
aggregate notification counts by status.
2025-12-02 10:31:00 +00:00
rcourtman
a1fd8420e4 test: Add scanNotification DLQ timestamp test
Test scanNotification with CompletedAt and LastAttempt populated
via DLQ path. Coverage: 61.9% → 81.0%
2025-12-02 03:04:37 +00:00
rcourtman
20e3c4c718 test: Add processNotification tests for all code paths
Test cancelled notification, no processor, success, and failure paths.
Coverage: 50.0% → 80.0%
2025-12-02 03:01:17 +00:00
rcourtman
4765a5fa78 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%
2025-12-02 02:58:10 +00:00
rcourtman
5be678f88d Add unit tests for notification queue utility functions
Test coverage for calculateBackoff (exponential backoff calculation),
NotificationQueueStatus constants, and QueuedNotification struct fields.
15 test cases covering backoff timing, cap behavior, and struct defaults.
2025-11-30 03:19:23 +00:00