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") } }