mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
28 lines
1.0 KiB
Go
28 lines
1.0 KiB
Go
package store
|
|
|
|
import (
|
|
"github.com/cosmic-clash/cosmic-clash/server/domain"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestQueueSQLUsesDurableIdempotencyAndOwnerScopedRecovery(t *testing.T) {
|
|
for query, fragments := range map[string][]string{
|
|
QueueIdempotencyInsertSQL: {"idempotency_keys", "ON CONFLICT (scope, idempotency_key) DO NOTHING", "payload_digest"},
|
|
QueueIdempotencySelectSQL: {"scope = $1", "idempotency_key = $2", "FOR UPDATE"},
|
|
QueueTicketSelectSQL: {"ticket_id = $1", "player_id = $2"}, QueueTicketInsertSQL: {"player_id", "playlist", "client_build", "protocol_version"},
|
|
} {
|
|
for _, fragment := range fragments {
|
|
if !contains(query, fragment) {
|
|
t.Fatalf("query %q missing %q", query, fragment)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCreateQueueTicketRejectsInvalidArgumentsWithoutDatabase(t *testing.T) {
|
|
if _, err := CreateQueueTicket(nil, nil, "ticket-1", "player-1", "short", domain.QueueSpec{Playlist: domain.Casual, ClientBuild: "build-1", ProtocolVersion: 1}, time.Unix(1000, 0)); err == nil {
|
|
t.Fatal("invalid arguments accepted")
|
|
}
|
|
}
|