(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestSweep_DoesNotDeleteRecentInProgress(t *testing.T) { |
| 274 | store, userID, _ := newStoreAndUser(t) |
| 275 | ctx := context.Background() |
| 276 | |
| 277 | hash := idempotency.HashBody([]byte(`{"a":1}`)) |
| 278 | first, _ := store.Claim(ctx, userID, "key-sweep-active", "/api/v1/send", hash) |
| 279 | if first.Outcome != idempotency.OutcomeAcquired { |
| 280 | t.Fatalf("first Outcome = %d", first.Outcome) |
| 281 | } |
| 282 | |
| 283 | if _, err := store.Sweep(ctx); err != nil { |
| 284 | t.Fatalf("Sweep: %v", err) |
| 285 | } |
| 286 | |
| 287 | // Active in_progress claim must survive sweep. |
| 288 | second, _ := store.Claim(ctx, userID, "key-sweep-active", "/api/v1/send", hash) |
| 289 | if second.Outcome != idempotency.OutcomeInFlight { |
| 290 | t.Errorf("Outcome = %d, want OutcomeInFlight (sweep should have kept active claim)", second.Outcome) |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | func TestClaim_ConcurrentSameKeyOnlyOneAcquires(t *testing.T) { |
| 295 | store, userID, _ := newStoreAndUser(t) |
nothing calls this directly
no test coverage detected