dbtest

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dbtest answers one question for every test that needs a PostgreSQL database: is there one, and is going without allowed here?

It exists because of a false green. A release gate reported both engines passing while the database had been down for two hours; the cached results were half of that and are fixed, and this is the other half. With no DSN every PostgreSQL test skips, `go test` prints `ok` for the package, and a run that exercised one engine is indistinguishable from a run that exercised two. Nothing was wrong with any individual skip — a developer without a database should still be able to work — and the composition of them is a gate that cannot say what it checked.

So the decision moves to the caller. TESSERA_REQUIRE_POSTGRES turns every absent DSN into a failure that names which variable is missing, and the release gate sets it. A run that does not set it is a developer run and skips as before, loudly enough to read.

Index

Constants

View Source
const Required = "TESSERA_REQUIRE_POSTGRES"

Required is the variable that makes an absent database a failure rather than a skip. Its value is not read: set means required.

Variables

This section is empty.

Functions

func Postgres

func Postgres(t *testing.T) string

Postgres returns the disposable database's DSN, or stops the test. The second DSN, for restore, is a separate database because a restore that wrote over the source would prove nothing about a restore.

func PostgresRestore

func PostgresRestore(t *testing.T) string

PostgresRestore returns the DSN a backup is restored into, or an empty string when there is none and this run allows that. It is a separate database because a restore that wrote over its source would prove nothing.

It does not skip, because its caller is a branch part-way through a test whose earlier assertions have already run, and marking the whole test skipped would misreport them. What it does instead is refuse to be silent: absence is a failure under Required, and a logged line otherwise.

This one was worse than a skip. The variable was read inline and the branch went quiet when it was empty, inside a test that went on to pass — so the package printed `ok`, the test printed nothing, and the only evidence that a backup restores at all had not run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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