mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
29 lines
1.3 KiB
Go
29 lines
1.3 KiB
Go
package store
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLiveAbandonmentSQLPreservesResultRosterAndReconnectFences(t *testing.T) {
|
|
for query, fragments := range map[string][]string{
|
|
liveAbandonmentCandidatesSQL: {"playlist = 'ranked'", "state = 'LIVE'", "abandoned_at IS NULL", "disconnected_at < $1", "LIMIT $2"},
|
|
liveAbandonmentMatchLockSQL: {"FOR UPDATE", "match_id = $1"},
|
|
liveAbandonmentParticipantsSQL: {"participation_active", "abandoned_at IS NULL", "disconnected_at IS NOT NULL", "FOR UPDATE"},
|
|
liveAbandonmentParticipantSQL: {"SET abandoned_at", "participation_active", "abandoned_at IS NULL", "RETURNING"},
|
|
liveAbandonmentPenaltySQL: {"MATCH_ABANDONED", "ON CONFLICT"},
|
|
liveAbandonmentRevisionSQL: {"state = 'LIVE'", "revision = revision + 1"},
|
|
liveAbandonmentOutboxSQL: {"state_changed", "revision"},
|
|
liveAbandonmentTargetsSQL: {"participation_active", "ORDER BY player_id"},
|
|
} {
|
|
for _, fragment := range fragments {
|
|
if !strings.Contains(query, fragment) {
|
|
t.Fatalf("query missing %q: %s", fragment, query)
|
|
}
|
|
}
|
|
}
|
|
if strings.Contains(liveAbandonmentParticipantSQL, "participation_active = FALSE") || strings.Contains(liveAbandonmentParticipantSQL, "queue_tickets") {
|
|
t.Fatal("live abandonment must retain participant and ticket for the result transaction")
|
|
}
|
|
}
|