Documentation ¶
Index ¶
- Constants
- func BeginAll() ([]*sql.Tx, error)
- func CreateTestDatabase(ctx context.Context, opts ...db.Option) (*db.Connection, error)
- func DefaultDB() *db.Connection
- func DefaultDBs() []*db.Connection
- func DropTestDatabase(ctx context.Context, conn *db.Connection, opts ...db.Option) error
- func RollbackAll(txs ...*sql.Tx) error
- type Option
- type Suite
- type SuiteAction
Constants ¶
const ( SuiteFailureTests = 1 SuiteFailureBefore = 2 SuiteFailureAfter = 3 )
FailureCodes
Variables ¶
This section is empty.
Functions ¶
func BeginAll ¶
BeginAll begins a transaction in each of the underlying connections. If an error is raised by *any* of the connections, t
func CreateTestDatabase ¶
CreateTestDatabase creates a randomized test database.
func DefaultDB ¶
func DefaultDB() *db.Connection
DefaultDB returns a default database connection for tests.
func DefaultDBs ¶
func DefaultDBs() []*db.Connection
DefaultDBs returns a default set database connections for tests.
func DropTestDatabase ¶
DropTestDatabase drops a database.
func RollbackAll ¶
RollbackAll calls `Rollback` on a set of transactions.
Types ¶
type Option ¶
type Option func(*Suite)
Option is a mutator for a test suite.
func OptWithDefaultDB ¶
func OptWithDefaultDB() Option
OptWithDefaultDB runs a test suite with a dedicated database connection.
func OptWithDefaultDBs ¶
OptWithDefaultDBs runs a test suite with a count of database connections. Note: this type of connection pool is used in rare circumstances for performance reasons; you probably want to use `OptWithDefaultDB` for your tests.
func OptWithStatementLabelRequired ¶ added in v1.20210603.3
func OptWithStatementLabelRequired() Option
OptWithStatementLabelRequired adds a defaultdb interceptor that enforces that statement labels must be present on all statements.
type Suite ¶
type Suite struct { M *testing.M Log logger.Log Before []SuiteAction After []SuiteAction }
Suite is a set of before and after actions for a given package tests.
type SuiteAction ¶
SuiteAction is a step that can be run either before or after package tests.