fix: bind queue candidates to their owner

This commit is contained in:
Josh Creek
2026-08-31 22:05:44 +01:00
parent b47c7dc3fa
commit 3b208ae860
3 changed files with 16 additions and 2 deletions
+14
View File
@@ -79,6 +79,20 @@ func TestQueueCreateIdempotencyIncludesCandidatePayload(t *testing.T) {
}
}
func TestQueueCreateRejectsCandidateOwnedByAnotherPlayer(t *testing.T) {
q := NewQueue()
now := time.Unix(1000, 0)
_, err := q.Create("player-a", "ticket-a", "create-key-123456", Candidate{
TicketID: "ticket-a", PlayerID: "player-b", EnqueuedAt: now,
}, now)
if !errors.Is(err, ErrConflict) {
t.Fatalf("mismatched candidate owner error = %v", err)
}
if got := q.Candidates(now); len(got) != 0 {
t.Fatalf("mismatched candidate was stored: %+v", got)
}
}
func TestQueueConcurrentCreateKeepsOneActiveTicketPerPlayer(t *testing.T) {
q := NewQueue()
now := time.Unix(1000, 0)