Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDBReady ¶ added in v2.0.1
EnsureDBReady is a helper utility that can be inserted into a test during development to make it simpler to run the test in isolation. Docker will be called to start a db that is read to be used with GetDatabase. Example usage:
dberr, cleanup := dbtest.EnsureDBReady(ctx) require.NoError(t, dberr) defer cleanup() _, db := dbtest.GetDatabase(t) defer db.Close()
While the code is somewhat robust to having existing dbs running, this is not intended to be left in the test code. The goal is that you can run individual tests via your IDE integrations or using the CLI, e.g.
go test -run ^TestRetentionHandler$`
func EqualCount ¶
func EqualCount(t *testing.T, db *sql.DB, expected int, table string, filter squirrel.Sqlizer, msgAndArgs ...interface{}) int
EqualCount asserts that the count of rows matches the expected value given the table and WHERE query and args.EqualCount Note that this is a simple COUNT of rows in a single table. More complex queries should be constructed by hand.
func GetDatabase ¶
GetDatabase gets a test database