Documentation
¶
Overview ¶
Package dbtest provides an env-aware store constructor for tests. When SHINYHUB_TEST_POSTGRES_DSN is set, New returns a Postgres-backed store in an isolated per-test database; otherwise it returns an in-memory SQLite store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a migrated store. SQLite (:memory:) by default; an isolated Postgres database when SHINYHUB_TEST_POSTGRES_DSN is set. The store (and any Postgres database it created) is closed/dropped on test cleanup.
func NewPostgres ¶ added in v0.8.2
NewPostgres returns a migrated, isolated Postgres store AND its DSN, so a test can hand the same database to child processes it spawns. It SKIPS the test when SHINYHUB_TEST_POSTGRES_DSN is unset - there is no SQLite fallback, because a two-process shared-lease test is meaningless on per-process in-memory SQLite.
func RequirePostgres ¶
RequirePostgres skips the test unless a Postgres DSN is configured. Use for Postgres-specific assertions (advisory locks, type behavior).
func SkipIfPostgres ¶
SkipIfPostgres skips a SQLite-only test (pragmas, VACUUM INTO, legacy adoption) when running against Postgres.
Types ¶
This section is empty.