Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func KeepDatabasesForFailed ¶
func KeepDatabasesForFailed() Option
KeepDatabasesForFailed returns an option which prevents test databases from being dropped if the test they are used in fails. Such test databases will also not be re-used in future tests. By default test databases will be re-used regardless of whether or not tests fail, and will be automatically dropped when the supervisor is shutdown.
This option is primarily useful for debugging. Generally it is expected to combine this option with the '-run' flag when running tests in order to inspect the state of the database for a specific failing test.
func WithKeepDatabasesForFailed ¶
WithKeepDatabasesForFailed returns an option which controls whether or not to keep test databases if a test using them fails.
func WithResetOp ¶
func WithResetOp(op ResetTestDBOp) Option
WithResetOp returns an option that specifies how to reset a test db in order to prepare it for future tests. By default this is set to DropAllTables().
type ResetTestDBOp ¶
type ResetTestDBOp interface {
// contains filtered or unexported methods
}
func DropAllTables ¶
func DropAllTables() ResetTestDBOp
func DropAllTablesExcept ¶
func DropAllTablesExcept(names ...string) ResetTestDBOp
func TruncateAllTables ¶
func TruncateAllTables() ResetTestDBOp
func TruncateAllTablesExcept ¶
func TruncateAllTablesExcept(names ...string) ResetTestDBOp
type Supervisor ¶
type Supervisor interface { // GetTestDB returns a db for use in testing. GetTestDB(t testing.TB) TestDB // Shutdown shuts down the supervisor, dropping any test databases it // owns. Shutdown(ctx context.Context) error }
A Supervisor is used to manage databases for use in a test suite.
func NewSupervisor ¶
func NewSupervisor(ctx context.Context, opts ...Option) (Supervisor, error)
NewSupervisor returns a new supervisor, which maintains a pool of test databases for use in testing.