feat: persist queue probe metadata

This commit is contained in:
Josh Creek
2026-09-01 09:37:47 +01:00
parent e170bcf0ef
commit 25cc182793
6 changed files with 64 additions and 24 deletions
+16
View File
@@ -14,6 +14,7 @@ func TestQueueSQLUsesDurableIdempotencyAndOwnerScopedRecovery(t *testing.T) {
QueueTicketInsertSQL: {"player_id", "playlist", "client_build", "protocol_version"},
QueueTicketHeartbeatSQL: {"player_id = $2", "revision = $3", "expires_at > $4", "RETURNING"},
QueueTicketCancelSQL: {"player_id = $2", "revision = $3", "state NOT IN", "RETURNING"},
QueueCandidateProjectionSQL: {"playlist = $1", "predicted_rtt", "expires_at > $2", "LIMIT $3"},
} {
for _, fragment := range fragments {
if !contains(query, fragment) {
@@ -23,6 +24,21 @@ func TestQueueSQLUsesDurableIdempotencyAndOwnerScopedRecovery(t *testing.T) {
}
}
func TestListQueuedCandidatesRejectsUnscopedOrUnboundedReads(t *testing.T) {
now := time.Unix(1000, 0)
for _, playlist := range []domain.Playlist{"", "invalid"} {
if _, err := ListQueuedCandidates(nil, nil, playlist, now, 4); err == nil {
t.Fatalf("playlist %q accepted", playlist)
}
}
if _, err := ListQueuedCandidates(nil, nil, domain.Casual, now, 0); err == nil {
t.Fatal("zero limit accepted")
}
if _, err := ListQueuedCandidates(nil, nil, domain.Casual, now, 1001); err == nil {
t.Fatal("unbounded limit accepted")
}
}
func TestQueueMutationAdaptersRejectInvalidArgumentsWithoutDatabase(t *testing.T) {
now := time.Unix(1000, 0)
if _, err := HeartbeatQueueTicket(nil, nil, "player-1", "ticket-1", "short", 0, now); err == nil {