Documentation
¶
Overview ¶
Package dbtest provides helpers for database integration tests.
Tests call AcquireDatabase to get an isolated, freshly migrated database. When the GATEWAYSSHD_TEST_DATABASE_HOST environment variable is not set (no postgres available), the helpers skip the test rather than fail it, so `go test ./...` still passes on a machine without docker.
Index ¶
Constants ¶
const TestDatabaseHostEnv = "GATEWAYSSHD_TEST_DATABASE_HOST"
TestDatabaseHostEnv is the environment variable holding the postgres host to run integration tests against. The Makefile test target sets it to the IP of the postgres container it launches.
Variables ¶
This section is empty.
Functions ¶
func AcquireDatabase ¶
AcquireDatabase provisions a fresh, migrated database for the given test and returns it with a cleanup func that closes the connection and drops the database. The test is skipped when GATEWAYSSHD_TEST_DATABASE_HOST is not set.
func AcquireDatabaseWithSettings ¶ added in v0.5.0
AcquireDatabaseWithSettings is AcquireDatabase but also returns the connection settings, so tests can open additional connections to the same database (e.g. tunneled through a peer node).
Types ¶
This section is empty.