testdb

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package testdb isolates integration tests and local QA in temporary PostgreSQL schemas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New migrates an isolated schema per top-level test and records setup cost. TEST_DATABASE_URL overrides the local worktree database, and is required in CI.

func Open

func Open(dsn string) (*bun.DB, error)

Open uses a small pool suitable for isolated tests and fixture processes.

Types

type Schema

type Schema struct {
	URL string
	// contains filtered or unexported fields
}

Schema owns a temporary schema. Close its application pools before Close.

func NewSchema

func NewSchema(ctx context.Context, baseURL string) (*Schema, error)

NewSchema creates an empty schema without touching existing application data.

func (*Schema) Close

func (s *Schema) Close(ctx context.Context) error

Close drops only the schema allocated by NewSchema and closes its pool.

Jump to

Keyboard shortcuts

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