mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 13:22:03 +00:00
feat(multiplayer): persist live reconnect abandonments
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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: {"participant_abandoned", "revision"},
|
||||
} {
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user