dbtest

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 13 Imported by: 0

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

View Source
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

func AcquireDatabase(test *testing.T) (db.Database, func())

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

func AcquireDatabaseWithSettings(test *testing.T) (db.Database, *db.Settings, func())

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL