Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlstoretest

package
v0.0.0-...-d97833b Latest Latest
Warning

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

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

Documentation

Overview

Package sqlstoretest provides migrated databases for tests (02 §6).

Packages using it should call it from TestMain so templates and the PostgreSQL container are cleaned up:

func TestMain(m *testing.M) { os.Exit(sqlstoretest.Main(m)) }

Index

Constants

This section is empty.

Variables

Logger discards output; tests that check logs build their own.

Functions

func Count

func Count(t testing.TB, db *sqlstore.DB, query string, args ...any) int

Count runs a "SELECT count(*) …" query on a SQLite test database through a separate read-only connection (use-case tests have no access to the Tx).

func ForEachDialect

func ForEachDialect(t *testing.T, fn func(t *testing.T, db *sqlstore.DB))

ForEachDialect runs fn as the subtests "sqlite" and "postgres".

func FreshPostgresDSN

func FreshPostgresDSN(t testing.TB) string

FreshPostgresDSN returns the DSN of a new, empty (unmigrated) database, for migration tests.

func Main

func Main(m *testing.M) int

Main runs the tests and removes templates and the PostgreSQL container afterwards.

func NewPostgres

func NewPostgres(t testing.TB) *sqlstore.DB

NewPostgres returns a store on a fresh database created from a migrated template in a shared postgres:17-alpine container. It skips the test unless LITURGIST_TEST_POSTGRES=1.

func NewSQLite

func NewSQLite(t testing.TB) *sqlstore.DB

NewSQLite returns a store on a private copy of a migrated template file.

func PostgresEnabled

func PostgresEnabled() bool

PostgresEnabled reports whether PostgreSQL tests should run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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