Documentation
¶
Overview ¶
Package testdb hands tests isolated, fully migrated PostgreSQL databases.
One PostgreSQL server is shared per test binary: either the one named by SLASHDOCS_TEST_DATABASE_URL (for CI environments without Docker) or a disposable container started via testcontainers. A template database is migrated once per schema version, and every call to New clones it, so each test gets a private database in a few milliseconds.
Index ¶
Constants ¶
const EnvURL = "SLASHDOCS_TEST_DATABASE_URL"
EnvURL is the environment variable that points tests at an existing PostgreSQL server instead of starting a container. The referenced role must be allowed to CREATE DATABASE.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a connection string for a fresh database that already has all migrations applied. The database is private to the calling test and dropped on cleanup. If no PostgreSQL server is reachable (no Docker and no SLASHDOCS_TEST_DATABASE_URL), the calling test is skipped with an explanation.
Types ¶
This section is empty.