From ffe31592569ccb5ff66e408eb9381a4d314e469d Mon Sep 17 00:00:00 2001 From: Matthew Meszaros Date: Fri, 18 Sep 2026 14:51:18 +0200 Subject: [PATCH] feat: order the repair sweep's fake inbox by id so the cursor assertion is deterministic like the query it stands in for --- internal/app/consumer/reply_repair_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/app/consumer/reply_repair_test.go b/internal/app/consumer/reply_repair_test.go index adc92946a..ad39df9d1 100644 --- a/internal/app/consumer/reply_repair_test.go +++ b/internal/app/consumer/reply_repair_test.go @@ -3,6 +3,7 @@ package jobs import ( "context" "errors" + "sort" "testing" "time" @@ -20,12 +21,14 @@ type repairInbox struct { func (r *repairInbox) ListUnprocessedCampaignReplies(_ context.Context, since time.Time, afterID uuid.UUID, limit int) ([]models.JobEventNewEmail, error) { r.since = since + // Ordered by id like the query, so the cursor is deterministic. var out []models.JobEventNewEmail for _, e := range r.events { if e.Message.ID.String() > afterID.String() { out = append(out, e) } } + sort.Slice(out, func(i, j int) bool { return out[i].Message.ID.String() < out[j].Message.ID.String() }) return out[:min(len(out), limit)], nil }