From 75aaf1391c3d15b1a00d4d073ec7494c2ad5ac4d Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 17:28:04 +0100 Subject: [PATCH] test(notifications): isolate queued routing snapshot SetProcessor wakes the live queue worker while this test processes a fetched row manually. Defer the row beyond GetPending before installing the processor so a competing worker cannot decide the synchronous assertion. Change-source: pulse-maintainer --- internal/notifications/queue_policy_change_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/notifications/queue_policy_change_test.go b/internal/notifications/queue_policy_change_test.go index c3b3c4b4f9..5837e6dfda 100644 --- a/internal/notifications/queue_policy_change_test.go +++ b/internal/notifications/queue_policy_change_test.go @@ -35,6 +35,13 @@ func TestQueuedEmailRoutingChangeAndResolution(t *testing.T) { t.Fatalf("queued email = %v, %v", pending, err) } old := pending[0] + // The queue's background worker starts at construction and SetProcessor + // wakes it. Keep this row out of GetPending while exercising the + // already-fetched worker snapshot synchronously below. + futureRetry := time.Now().Add(time.Hour) + if _, err := q.db.Exec(`UPDATE notification_queue SET next_retry_at = ? WHERE id = ?`, futureRetry.Unix(), old.ID); err != nil { + t.Fatal(err) + } n.SetInitialNotifyTarget("webhook") // A fetched worker item must not defeat resolution cancellation. if resolve {