Documentation
¶
Overview ¶
Package pgtest confines each test that writes to a live PostgreSQL to a schema of its own.
`go test ./...` runs packages in parallel, and more than one of them opens the database CHRONICLE_TEST_POSTGRES_DSN names. Store.Migrate runs every migration's ALTER TABLE on each call, so two packages migrating and appending in the shared public schema at once can deadlock each other. A schema per test gives each one tables nobody else touches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Schema ¶
Schema creates a randomly named schema in the database dsn names, drops it again when the test ends, and returns dsn with search_path pinned to it. The migrations create their tables unqualified, so they land inside it.
Open the pool on the returned DSN after calling Schema. Cleanups run last registered first, so the pool's close then fires before the drop, which would otherwise block on the pool's open connections.
It refuses the default port. On the machine these tests were written on, that is another project's live database.
Types ¶
This section is empty.