feat: use postgres

This commit is contained in:
Ilia Denisov
2026-04-26 20:34:39 +02:00
committed by GitHub
parent 48b0056b49
commit fe829285a6
365 changed files with 29223 additions and 24049 deletions
+5 -34
View File
@@ -1,7 +1,11 @@
// Package racenamedirtest exposes the shared behavioural test suite that
// every ports.RaceNameDirectory implementation must pass. The Redis
// every ports.RaceNameDirectory implementation must pass. The PostgreSQL
// adapter and the in-process stub run the same cases so both back ends
// stay behaviourally equivalent.
//
// Subtests run sequentially: the PostgreSQL adapter shares one
// testcontainers instance across the suite and relies on TruncateAll
// between factory invocations, which would race under t.Parallel.
package racenamedirtest
import (
@@ -29,144 +33,111 @@ func Run(t *testing.T, factory Factory) {
t.Helper()
t.Run("Canonicalize rejects invalid input", func(t *testing.T) {
t.Parallel()
testCanonicalizeRejectsInvalid(t, factory)
})
t.Run("Canonicalize is deterministic", func(t *testing.T) {
t.Parallel()
testCanonicalizeDeterministic(t, factory)
})
t.Run("Check empty directory", func(t *testing.T) {
t.Parallel()
testCheckEmpty(t, factory)
})
t.Run("Check treats actor as own holder", func(t *testing.T) {
t.Parallel()
testCheckActorNotTaken(t, factory)
})
t.Run("Check exposes holder and kind to other users", func(t *testing.T) {
t.Parallel()
testCheckHolderAndKind(t, factory)
})
t.Run("Reserve records new holding", func(t *testing.T) {
t.Parallel()
testReserveRecords(t, factory)
})
t.Run("Reserve idempotent for same holder same game", func(t *testing.T) {
t.Parallel()
testReserveIdempotent(t, factory)
})
t.Run("Reserve allows same user across games", func(t *testing.T) {
t.Parallel()
testReserveCrossGame(t, factory)
})
t.Run("Reserve rejects cross-user same game", func(t *testing.T) {
t.Parallel()
testReserveCrossUserSameGame(t, factory)
})
t.Run("Reserve rejects cross-user different games", func(t *testing.T) {
t.Parallel()
testReserveCrossUserDifferentGames(t, factory)
})
t.Run("Reserve rejects invalid name", func(t *testing.T) {
t.Parallel()
testReserveInvalidName(t, factory)
})
t.Run("ReleaseReservation missing", func(t *testing.T) {
t.Parallel()
testReleaseReservationMissing(t, factory)
})
t.Run("ReleaseReservation wrong holder", func(t *testing.T) {
t.Parallel()
testReleaseReservationWrongHolder(t, factory)
})
t.Run("ReleaseReservation clears sole binding", func(t *testing.T) {
t.Parallel()
testReleaseReservationClears(t, factory)
})
t.Run("ReleaseReservation swallows invalid name", func(t *testing.T) {
t.Parallel()
testReleaseReservationInvalidName(t, factory)
})
t.Run("ReleaseReservation keeps cross-game holding visible", func(t *testing.T) {
t.Parallel()
testReleaseReservationKeepsCrossGame(t, factory)
})
t.Run("MarkPendingRegistration promotes reservation", func(t *testing.T) {
t.Parallel()
testMarkPendingPromotes(t, factory)
})
t.Run("MarkPendingRegistration idempotent same eligible", func(t *testing.T) {
t.Parallel()
testMarkPendingIdempotent(t, factory)
})
t.Run("MarkPendingRegistration rejects different eligible", func(t *testing.T) {
t.Parallel()
testMarkPendingDifferentEligible(t, factory)
})
t.Run("MarkPendingRegistration rejects missing reservation", func(t *testing.T) {
t.Parallel()
testMarkPendingMissing(t, factory)
})
t.Run("ExpirePendingRegistrations empty", func(t *testing.T) {
t.Parallel()
testExpirePendingEmpty(t, factory)
})
t.Run("ExpirePendingRegistrations releases expired entries", func(t *testing.T) {
t.Parallel()
testExpirePendingReleasesExpired(t, factory)
})
t.Run("ExpirePendingRegistrations skips future entries", func(t *testing.T) {
t.Parallel()
testExpirePendingSkipsFuture(t, factory)
})
t.Run("ExpirePendingRegistrations idempotent replay", func(t *testing.T) {
t.Parallel()
testExpirePendingIdempotent(t, factory)
})
t.Run("Register converts pending to registered", func(t *testing.T) {
t.Parallel()
testRegisterConverts(t, factory)
})
t.Run("Register idempotent on repeat", func(t *testing.T) {
t.Parallel()
testRegisterIdempotent(t, factory)
})
t.Run("Register rejects missing pending", func(t *testing.T) {
t.Parallel()
testRegisterMissingPending(t, factory)
})
t.Run("Register rejects expired pending", func(t *testing.T) {
t.Parallel()
testRegisterExpiredPending(t, factory)
})
t.Run("List methods partition correctly", func(t *testing.T) {
t.Parallel()
testListsPartition(t, factory)
})
t.Run("ReleaseAllByUser clears every kind", func(t *testing.T) {
t.Parallel()
testReleaseAllByUserClears(t, factory)
})
t.Run("ReleaseAllByUser leaves other users intact", func(t *testing.T) {
t.Parallel()
testReleaseAllByUserIsolated(t, factory)
})
t.Run("ReleaseAllByUser idempotent", func(t *testing.T) {
t.Parallel()
testReleaseAllByUserIdempotent(t, factory)
})
t.Run("Honors canceled context", func(t *testing.T) {
t.Parallel()
testContextCancellation(t, factory)
})
}