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

sqltest

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sqltest opens, in an app's tests, the test database that aicoded check makes for the app: a database of its own with the app's tables, which the tests reach as the app's data user, who reads and writes rows and changes no table.

func TestAddNote(t *testing.T) {
	db := sqltest.Open(t)
	...
}

aicoded check makes the test database when the app declares sqldb and dev.yaml names a MySQL server, and puts its address in AICODED_TEST_DB; elsewhere, Open skips the test.

Index

Constants

View Source
const EnvDB = "AICODED_TEST_DB"

EnvDB is the variable that holds the DSN of the test database.

Variables

This section is empty.

Functions

func Open

func Open(t testing.TB) *sql.DB

Open returns the pool of connections to the test database, closed when the test ends. Times are read and written in UTC and one statement runs per call, as with sqldb.Open. It skips the test when AICODED_TEST_DB is unset or empty, and fails it when the variable does not hold a DSN, without quoting it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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