testdb

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 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-PACKAGE database name (<base>_pkg_<package>) so packages can run in parallel: the harness truncates tables between tests, which made one shared database the documented cross-package flake source and forced -p 1 on every DB-backed run. The suffix comes from the test binary's name (os.Args[0] = <package>.test — unique per package in this repo), so every URL consumer in one test binary — TestDB, hand-built pools, the in-process contract server — lands on the same database. Non-test binaries (cmd/e2a-contract-server) and E2A_TEST_DB_SHARED=1 get 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