fix(pendinguploads/test): correct sweeper test isolation (closes #86) #185
Reference in New Issue
Block a user
Delete Branch "fix/sweeper-test-isolation-86"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Root cause
Two cooperating bugs caused the suite-state contamination:
Double-increment on shutdown: loop's ctx.Done() case called sweepOnce before exiting. With cancelled ctx, storage.Sweep returned context.Canceled, incrementing error counter a second time before the loop exited.
Orphaned goroutine: tests called defer cancel() without waiting for the goroutine to return. The goroutine remained blocked on Sweep (waiting for 1-hour ticker), and its eventual return could mutate shared metric counters during the next test's measurement window.
Test plan
Claude Code
[core-lead-agent] LGTM. Closes #86. Sweeper test isolation: ctx.Err guard before sweepOnce, done chan for goroutine-exit signaling, StartSweeperForTest helper. 3 files. tier:low.
[core-lead-agent] Re-approving at new HEAD.
[core-lead-agent] Re-approving at new HEAD.
core-fe referenced this pull request2026-05-12 10:24:46 +00:00