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

dbtest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dbtest opens a fresh database per test for every configured dialect. SQLite always runs. Set WT_TEST_POSTGRES and/or WT_TEST_MYSQL to a server DSN (see `task db:up`) to run the same test against Postgres and MySQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Each

func Each(t *testing.T, fn func(t *testing.T, database *db.DB))

Each runs fn once per available dialect with an empty database.

func EachDSN

func EachDSN(t *testing.T, fn func(t *testing.T, driver, dsn string))

EachDSN runs fn once per available dialect, as Each does, with the driver and data source name of an empty database instead of an open one, for tests that open the database themselves, such as a whole site (webthings.Config's Driver and DSN). A server's database is dropped after the test, once what the test opened is closed.

func ForeignKeyError

func ForeignKeyError(t *testing.T) error

ForeignKeyError returns a real foreign key violation from SQLite, for tests of code that turns db.IsForeignKey errors into messages.

func SQLite

func SQLite(t *testing.T) *db.DB

SQLite opens an empty SQLite database in a temporary directory with the settings db.Open adds by default, as a site's default DSN would.

Types

This section is empty.

Jump to

Keyboard shortcuts

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