diff options
| author | historia <[not public]> | 2026-09-18 18:38:35 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 18:38:35 -0400 |
| commit | 1f118d79e319da4e765502e9ca5b661772de94f1 (patch) | |
| tree | bca8a3fd1e538f1c302480511e6ba872c92e10b8 /internal/game/hardening_queue_cleanup_test.go | |
| parent | 5ad42a51df4dcc5ccc3aa6a6d902085ce2ee4239 (diff) | |
| download | thehouseoficarus-1f118d79e319da4e765502e9ca5b661772de94f1.tar.gz | |
refactor: casino table core; fix: stake/migration/validation gaps
Diffstat (limited to 'internal/game/hardening_queue_cleanup_test.go')
| -rw-r--r-- | internal/game/hardening_queue_cleanup_test.go | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/internal/game/hardening_queue_cleanup_test.go b/internal/game/hardening_queue_cleanup_test.go index 95b96bf..3285381 100644 --- a/internal/game/hardening_queue_cleanup_test.go +++ b/internal/game/hardening_queue_cleanup_test.go @@ -114,24 +114,27 @@ func TestProcessQueuedCommandsSkipsStaleSession(t *testing.T) { } } -// TestActivePositionsReturnsSortedNamesAndOneBasedPosition pins the documented -// contract of ActivePositions: names sorted, position 1-indexed, 0 when the -// player holds no active command. -func TestActivePositionsReturnsSortedNamesAndOneBasedPosition(t *testing.T) { +// TestActivePositionsReturnsResolutionOrderAndOneBasedPosition pins the +// contract of ActivePositions: names in actual resolution order (earliest +// Timestamp first, matching ProcessQueuedCommands), position 1-indexed, 0 when +// the player holds no active command. +func TestActivePositionsReturnsResolutionOrderAndOneBasedPosition(t *testing.T) { q := NewCommandQueue() - for _, name := range []string{"carol", "alice", "bob"} { - q.EnqueueActive(name, QueuedCommand{Command: "look", Timestamp: time.Now()}) - } + base := time.Now() + // Queue deliberately out of alphabetical order: resolution is first-to-queue. + q.EnqueueActive("alice", QueuedCommand{Command: "look", Timestamp: base.Add(3 * time.Millisecond)}) + q.EnqueueActive("bob", QueuedCommand{Command: "look", Timestamp: base.Add(2 * time.Millisecond)}) + q.EnqueueActive("carol", QueuedCommand{Command: "look", Timestamp: base.Add(1 * time.Millisecond)}) names, pos := q.ActivePositions("bob") - if want := []string{"alice", "bob", "carol"}; !reflect.DeepEqual(names, want) { - t.Errorf("names = %v, want %v", names, want) + if want := []string{"carol", "bob", "alice"}; !reflect.DeepEqual(names, want) { + t.Errorf("names = %v, want %v (timestamp order)", names, want) } if pos != 2 { t.Errorf("position of bob = %d, want 2", pos) } - if _, pos := q.ActivePositions("alice"); pos != 1 { - t.Errorf("position of alice = %d, want 1", pos) + if _, pos := q.ActivePositions("carol"); pos != 1 { + t.Errorf("position of carol = %d, want 1", pos) } if _, pos := q.ActivePositions("nobody"); pos != 0 { t.Errorf("position of an unqueued player = %d, want 0", pos) |
