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 ¶
- Variables
- func Count(t testing.TB, db *sqlstore.DB, query string, args ...any) int
- func ForEachDialect(t *testing.T, fn func(t *testing.T, db *sqlstore.DB))
- func FreshPostgresDSN(t testing.TB) string
- func Main(m *testing.M) int
- func NewPostgres(t testing.TB) *sqlstore.DB
- func NewSQLite(t testing.TB) *sqlstore.DB
- func PostgresEnabled() bool
Constants ¶
This section is empty.
Variables ¶
var Logger = slog.New(slog.NewTextHandler(io.Discard, nil))
Logger discards output; tests that check logs build their own.
Functions ¶
func Count ¶
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 ¶
ForEachDialect runs fn as the subtests "sqlite" and "postgres".
func FreshPostgresDSN ¶
FreshPostgresDSN returns the DSN of a new, empty (unmigrated) database, for migration tests.
func NewPostgres ¶
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 PostgresEnabled ¶
func PostgresEnabled() bool
PostgresEnabled reports whether PostgreSQL tests should run.
Types ¶
This section is empty.