testdb

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseTestDBURL

func BaseTestDBURL() string

BaseTestDBURL returns the configured base URL without the per-workspace, per-package suffix — the database an administrative probe connects to.

func OpenPreparedTestDB

func OpenPreparedTestDB(ctx context.Context, dbURL string) (*pgxpool.Pool, error)

func TestDB

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

func TestDBURL

func TestDBURL() string

TestDBURL returns the database URL tests should use. Inside a `go test` binary it derives a PER-WORKSPACE, PER-BINARY database name (<base>_ws<workspace>_pkg_<binary>) so packages can run in parallel and separate checkouts cannot truncate each other's rows: the harness truncates tables between tests, which made shared databases the documented cross-package and cross-worktree flake source. The suffix comes from the binary's name (os.Args[0] = <package>.test for go test), so every URL consumer in one process — TestDB, hand-built pools, and the in-process contract server — lands on the same database. E2A_TEST_DB_SHARED=1 gets the base URL verbatim. Missing databases self-provision on first open (see OpenPreparedTestDB). Concurrent sessions, agents, and worktrees are isolated by the per-workspace component below, so handing each runner its own base URL is no longer required — only useful for pointing a run at an entirely separate server.

func Truncate

func Truncate(ctx context.Context, pool *pgxpool.Pool) error

Truncate empties every application table, for callers that own their own lifecycle (the contract server's Close) rather than a *testing.T.

func TruncateAll

func TruncateAll(t *testing.T, pool *pgxpool.Pool)

Types

This section is empty.

Jump to

Keyboard shortcuts

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