Documentation
¶
Overview ¶
Package pgtest resets shared PostgreSQL fixtures between tests. Packages must run serially because they share the database selected by PG_TEST_DSN:
PG_TEST_DSN=... go test ./... -count=1 -tags=integration -p 1
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Reset ¶
Reset empties every user table in the current schema — except the migration bookkeeping table — and restarts identity sequences, so fixture primary keys are deterministic across runs. Call it right after opening the database and before AutoMigrate.
All tables are truncated together so intra-schema foreign keys need no deletion order. Do not use CASCADE: a foreign key from another schema must fail the reset, not silently clear another fixture. ONLY likewise prevents PostgreSQL from implicitly including descendants in another schema. Table identifiers are quoted by PostgreSQL itself.
Types ¶
This section is empty.