testdb

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testdb opens the database that package tests run against. It imports only pkg/migrations (and, through it, pkg/models and pkg/identifiers) and pkg/sqliteconn, so tests in every other package can use it without an import cycle, including the packages pkg/testutils imports. The internal tests of pkg/migrations, pkg/models, and pkg/identifiers are the exception: they would import their own package through this one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t testing.TB) *bun.DB

New returns an in-memory SQLite database migrated to the latest schema, with foreign keys on, that is closed when the test ends. Each call returns a separate database, so parallel tests do not share rows.

The pool is pinned to one connection, as pkg/database does in production: every connection to ":memory:" opens its own empty database. PRAGMA foreign_keys applies only to the connection that ran it, so sqliteconn runs it on every connection the pool opens, as pkg/database does. A replacement connection, opened after a query is canceled mid-statement, has foreign keys on but sees a new empty ":memory:" database, so the schema is gone.

Types

This section is empty.

Jump to

Keyboard shortcuts

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