package
0.0.0-20250307173044-634e8ce82c05
Repository: https://github.com/sapcc/go-bits.git
Documentation: pkg.go.dev
# Functions
AssertDBContent makes a dump of the database contents (as a sequence of INSERT statements) and runs diff(1) against the given file, producing a test error if these two are different from each other.
ClearContentsWith is a TestSetupOption that removes records from the DB using the provided SQL statement.
ClearTables is a TestSetupOption that removes all rows from the given tables.
Connect connects to a Postgres database.
ConnectForTest connects to the test database server managed by func WithTestDB().
LoadSQLFile is a TestSetupOption that loads a file containing SQL statements and executes them all.
NewTracker creates a new Tracker.
OverrideDatabaseName is a TestSetupOption that picks a different database name than the default of t.Name().
ResetPrimaryKeys is a TestSetupOption that resets the sequences for the "id" column of the given tables to start at 1 again (or if there are entries in the table, to start right after the entry with the highest ID).
URLFrom constructs a libpq connection URL from the provided parts.
WithTestDB spawns a PostgreSQL database for the duration of a `go test` run.
# Structs
Assertable contains a set of SQL statements.
Configuration contains settings for Init().
Tracker keeps a copy of the database contents and allows for checking the database contents (or changes made to them) during tests.
URLParts contains the arguments for func URLFrom(), see documentation over there.
# Interfaces
TestingT is implemented by *testing.T, and also satisfied by ginkgo.GinkgoT().
# Type aliases
TestSetupOption is an optional behavior that can be given to ConnectForTest().