dbtest

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package dbtest provides an env-aware store constructor for tests. When SHINYHUB_TEST_POSTGRES_DSN is set, New returns a Postgres-backed store in an isolated per-test database; otherwise it returns an in-memory SQLite store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t *testing.T) *db.Store

New returns a migrated store. SQLite (:memory:) by default; an isolated Postgres database when SHINYHUB_TEST_POSTGRES_DSN is set. The store (and any Postgres database it created) is closed/dropped on test cleanup.

func NewPostgres added in v0.8.2

func NewPostgres(t *testing.T) (*db.Store, string)

NewPostgres returns a migrated, isolated Postgres store AND its DSN, so a test can hand the same database to child processes it spawns. It SKIPS the test when SHINYHUB_TEST_POSTGRES_DSN is unset - there is no SQLite fallback, because a two-process shared-lease test is meaningless on per-process in-memory SQLite.

func RequirePostgres

func RequirePostgres(t *testing.T)

RequirePostgres skips the test unless a Postgres DSN is configured. Use for Postgres-specific assertions (advisory locks, type behavior).

func SkipIfPostgres

func SkipIfPostgres(t *testing.T)

SkipIfPostgres skips a SQLite-only test (pragmas, VACUUM INTO, legacy adoption) when running against Postgres.

Types

This section is empty.

Jump to

Keyboard shortcuts

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