Documentation
¶
Overview ¶
Package testhelpers provides shared testcontainers-go setup for PG and CH used by per-package integration tests and the e2e boot test.
This package is never imported by production code, so it (and its testcontainers dependency tree) is absent from the final binary. The test-only build path is enforced socially — no //go:build tag — but a CI check could grep for production imports if drift becomes a worry.
Index ¶
- func StartClickHouse(t *testing.T) (*sql.DB, config.Config)
- func StartClickHouseC(t *testing.T) (*sql.DB, config.Config, testcontainers.Container)
- func StartPostgres(t *testing.T) (*pgxpool.Pool, config.Config)
- func StartPostgresC(t *testing.T) (*pgxpool.Pool, config.Config, testcontainers.Container)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartClickHouse ¶
StartClickHouse boots a fresh clickhouse-server container with admin credentials matching what the app expects (mere_admin), and returns an admin-authenticated *sql.DB plus a Config pre-populated with the container's host/port. The readonly user is NOT pre-provisioned — that's what the app's ProvisionReadonlyUser is supposed to do, so the integration tests cover it.
func StartClickHouseC ¶
StartClickHouseC is StartClickHouse plus the raw container handle, for tests that Stop/Start the dependency to exercise recovery paths. Unlike StartClickHouse it pins the native 9000 port to a fixed host port, because Docker reassigns an ephemeral port on Stop/Start — pinning lets the returned *sql.DB reconnect on the same address after a restart.
func StartPostgres ¶
StartPostgres boots a fresh postgres:16 container, waits until it accepts connections, and returns a connected pgxpool plus a Config pre-populated with the container's host/port and credentials. The container and pool are torn down via t.Cleanup. The host port is ephemeral.
func StartPostgresC ¶
StartPostgresC is StartPostgres plus the raw container handle, for tests that Stop/Start the dependency to exercise recovery paths. Unlike StartPostgres it pins a fixed host port, because Docker reassigns an ephemeral port on Stop/Start — pinning lets the returned pool reconnect on the same address after a restart.
Types ¶
This section is empty.