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 ¶
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 ¶
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.