Documentation
¶
Overview ¶
Package storetest provisions throwaway, fully isolated Postgres databases for the akari server's integration tests.
NewStore is the one entry point every integration test uses, in the spirit of Rust's sqlx::test: it hands back a Store backed by a uniquely named database that was just created and migrated, and dropped again when the test finishes. Because no two tests share a database, the suite runs at Go's default package parallelism and individual tests may call t.Parallel. This replaces the older shared-database harness, where each test reset the global `public` schema in one database, so concurrent packages clobbered each other's schema_migrations table and the suite had to be serialized with `go test -p 1`.
Index ¶
Constants ¶
const EnvDatabaseURL = "AKARI_TEST_DATABASE_URL"
EnvDatabaseURL is the environment variable that opts a run in to the integration tests. Its value is a normal Postgres URL; only the host and credentials are used to reach the server, since each test's database is created beside the one the URL names rather than being it.
Variables ¶
This section is empty.
Functions ¶
func NewStore ¶
NewStore returns a Store backed by its own isolated, freshly migrated database. The test is skipped when EnvDatabaseURL is unset, so a developer without a Postgres handy still gets a green (skipped) run.
The database is dropped on t.Cleanup with WITH (FORCE), which terminates any connection still attached. That keeps cleanup robust when a test fails or leaves its pool open, so a run never leaks databases behind it.
Types ¶
This section is empty.