Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // TruncateTimeout is the maximum time duration for truncation calls. (Default: 5 seconds) TruncateTimeout = 5 * time.Second )
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface { ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) }
Agent defines a common set of methods for executing stored procedures, statements or queries.
type GenericTruncator ¶ added in v0.3.0
type GenericTruncator struct {
// contains filtered or unexported fields
}
GenericTruncator represents a common set of methods for truncating a database during testing.
func (*GenericTruncator) MustTruncateAll ¶ added in v0.3.0
func (tr *GenericTruncator) MustTruncateAll(t testing.TB)
MustTruncateAll will run TruncateAll and fail test if it's unsuccessful.
func (*GenericTruncator) MustTruncateTables ¶ added in v0.3.0
func (tr *GenericTruncator) MustTruncateTables(t testing.TB, tables ...string)
MustTruncateTables will run TruncateTables and will fail test if it can't.
func (*GenericTruncator) TruncateAll ¶ added in v0.3.0
func (tr *GenericTruncator) TruncateAll(t testing.TB) error
TruncateAll will empty all tables in the database.
func (*GenericTruncator) TruncateTables ¶ added in v0.3.0
func (tr *GenericTruncator) TruncateTables(t testing.TB, tables ...string) error
TruncateTables removes all content in the given tables.
type MySQLTruncator ¶ added in v0.3.0
type MySQLTruncator struct {
// contains filtered or unexported fields
}
MySQLTruncator represents a set of methods for truncating for MySQL specifically.
func (*MySQLTruncator) MustTruncateAll ¶ added in v0.3.0
func (tr *MySQLTruncator) MustTruncateAll(t testing.TB)
MustTruncateAll will run TruncateAll and fail test if it's unsuccessful.
func (*MySQLTruncator) MustTruncateTables ¶ added in v0.3.0
func (tr *MySQLTruncator) MustTruncateTables(t testing.TB, tables ...string)
MustTruncateTables will run TruncateTables and will fail test if it can't.
func (*MySQLTruncator) TruncateAll ¶ added in v0.3.0
func (tr *MySQLTruncator) TruncateAll(t testing.TB) error
TruncateAll will empty all tables in the database.
func (*MySQLTruncator) TruncateTables ¶ added in v0.3.0
func (tr *MySQLTruncator) TruncateTables(t testing.TB, tables ...string) error
TruncateTables removes all content in the given tables.
type Truncator ¶
type Truncator interface { TruncateAll(t testing.TB) error TruncateTables(t testing.TB, tables ...string) error MustTruncateAll(t testing.TB) MustTruncateTables(t testing.TB, tables ...string) }
Truncator represents a common set of methods for truncating tables in a database.
func NewTruncator ¶
NewTruncator opens a new truncator for a database.