sqltest

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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