mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
feat: persist participant-scoped proposal recovery
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestProposalRecoverySQLBindsParticipantAndExpiresAtReadBoundary(t *testing.T) {
|
||||
for query, fragments := range map[string][]string{
|
||||
ProposalExpireSQL: {"state = 'OPEN'", "expires_at <= $2", "revision = revision + 1"},
|
||||
ProposalParticipantExpireSQL: {"response = 'PENDING'", "response = 'TIMED_OUT'"},
|
||||
ProposalRecoverySelectSQL: {"proposal_id = $1", "player_id = $2", "EXISTS"},
|
||||
ProposalParticipantsSelectSQL: {"proposal_id = $1", "ORDER BY player_id"},
|
||||
} {
|
||||
for _, fragment := range fragments {
|
||||
if !contains(query, fragment) {
|
||||
t.Fatalf("query %q missing %q", query, fragment)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProposalRecoveryRejectsMissingAuthorityInputs(t *testing.T) {
|
||||
if _, err := GetProposal(nil, nil, "player-1", "proposal-1", time.Unix(1000, 0)); err == nil {
|
||||
t.Fatal("nil database accepted")
|
||||
}
|
||||
if _, err := GetProposal(nil, nil, "", "proposal-1", time.Unix(1000, 0)); err == nil {
|
||||
t.Fatal("empty player accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user