mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-24 04:33:17 +00:00
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
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user