pgtest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package pgtest is test support: it starts one Dockerized Postgres per test binary and hands out freshly-migrated databases, the same pattern the store/events/api suites carry privately. New packages use this shared copy; production code must never import it. A missing Docker daemon is a hard failure, not a skip: skipped contract tests would silently hollow out the coverage gate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(m *testing.M) int

Main wraps testing.M: it starts the shared container, runs the suite, and tears the container down. Use from TestMain: os.Exit(pgtest.Main(m)).

func NewPool

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

NewPool creates a fresh database in the shared container, migrates it, and returns a pool closed at test end.

func NewSession

func NewSession(t *testing.T, pool *pgxpool.Pool, envKind string) (sessionID, envID domain.ID)

NewSession inserts the minimum fixture rows (agent, agent version, environment of the given kind, session) and returns the session and environment ids.

func NewSessionInEnv

func NewSessionInEnv(t *testing.T, pool *pgxpool.Pool, envID domain.ID) (sessionID domain.ID)

NewSessionInEnv inserts an additional idle session (with its own throwaway agent + version) into an existing environment and returns the session id. Use it to place several sessions — and thus several work items — under one environment, since Enqueue dedupes per (session, kind) while a live item exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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