testsupport

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testsupport provides shared helpers for integration tests that need a real Postgres database.

Index

Constants

View Source
const EnvURL = "LEGANT_TEST_DATABASE_URL"

EnvURL points at a Postgres the tests may create throwaway databases on.

Variables

This section is empty.

Functions

func DB

func DB(t *testing.T) *pgxpool.Pool

DB provisions a fresh, migrated, throwaway database for the calling test and returns a pool to it. Each call gets its own database (dropped at cleanup), so integration tests are fully isolated and safe to run in parallel across packages — even when they reset shared tables like signing_keys. The test is skipped when LEGANT_TEST_DATABASE_URL is unset (unless LEGANT_REQUIRE_DB is set, e.g. in CI, where an unset URL is a hard failure).

func Truncate

func Truncate(t *testing.T, pool *pgxpool.Pool, tables ...string)

Truncate empties the given tables (resetting identities). With per-test database isolation this is rarely needed, but remains for tests that reset state mid-run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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