mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
feat: add result transaction SQL boundary
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package store
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestResultSQLPreservesReceiptConflictAndAtomicCommitBoundaries(t *testing.T) {
|
||||
checks := map[string][]string{
|
||||
ResultReceiptInsertSQL: {"ON CONFLICT DO NOTHING", "payload_digest", "integrity_state"},
|
||||
ResultReceiptSelectSQL: {"FOR UPDATE", "committed_at"},
|
||||
ResultCommitLockSQL: {"server_id = $2", "FOR UPDATE"},
|
||||
ResultMatchCompleteSQL: {"state = 'RESULT_PENDING'", "revision = revision + 1"},
|
||||
ResultOutboxSQL: {"match_completed", "aggregate_id", "revision"},
|
||||
RatingLockSQL: {"ORDER BY player_id", "FOR UPDATE"},
|
||||
}
|
||||
for query, fragments := range checks {
|
||||
for _, fragment := range fragments {
|
||||
if !contains(query, fragment) {
|
||||
t.Fatalf("query %q missing %q", query, fragment)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func contains(value, fragment string) bool {
|
||||
for i := 0; i+len(fragment) <= len(value); i++ {
|
||||
if value[i:i+len(fragment)] == fragment {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user