testdb

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testdb starts ephemeral Postgres/Redis containers for integration tests. Each helper accepts an env-var name; when that variable is set it is returned verbatim (caller-supplied infrastructure wins). Otherwise a testcontainers-go container is started and registered for cleanup.

If neither path produces a usable backend (e.g. Docker is unavailable), the test is skipped with a clear message — the same outcome as the legacy "skip when env var unset" pattern, but with automatic local containers when Docker is running and CI doesn't need to set env vars.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Postgres

func Postgres(t *testing.T, envVar string) string

Postgres returns a Postgres DSN. Resolution order:

  1. If envVar is non-empty and the env var is set, return its value.
  2. Otherwise start an ephemeral postgres testcontainer and register cleanup. The DSN points at the new container.
  3. If the container can't start (e.g. Docker unavailable), t.Skip.

func Redis

func Redis(t *testing.T, envVar string) string

Redis returns a Redis address (host:port). Resolution order matches Postgres above: env var → testcontainer → t.Skip.

Types

This section is empty.

Jump to

Keyboard shortcuts

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