Documentation
¶
Index ¶
- Constants
- Variables
- func SharedTestMain(m *testing.M, postRunHooks ...func() error)
- func TestSchema() string
- func WithConnectionToContainer(t *testing.T, fn func(*sql.DB, string))
- func WithMigratorAndConnectionToContainer(t *testing.T, fn func(mig *roll.Roll, db *sql.DB))
- func WithMigratorAndConnectionToContainerWithOptions(t *testing.T, opts []roll.Option, fn func(mig *roll.Roll, db *sql.DB))
- func WithMigratorAndStateAndConnectionToContainerWithOptions(t *testing.T, opts []roll.Option, fn func(*roll.Roll, *state.State, *sql.DB))
- func WithMigratorInSchemaAndConnectionToContainer(t *testing.T, schema string, fn func(mig *roll.Roll, db *sql.DB))
- func WithMigratorInSchemaAndConnectionToContainerWithOptions(t testing.TB, schema string, opts []roll.Option, ...)
- func WithStateAndConnectionToContainer(t *testing.T, fn func(*state.State, *sql.DB))
- func WithStateInSchemaAndConnectionToContainer(t *testing.T, schema string, fn func(*state.State, *sql.DB))
- func WithUninitializedState(t *testing.T, fn func(*state.State))
- type MockSQLTransformer
Constants ¶
const ( CheckViolationErrorCode string = "check_violation" ExclusionViolationErrorCode string = "exclusion_violation" FKViolationErrorCode string = "foreign_key_violation" NotNullViolationErrorCode string = "not_null_violation" UndefinedColumnErrorCode string = "undefined_column" UndefinedTableErrorCode string = "undefined_table" UniqueViolationErrorCode string = "unique_violation" )
const MockSQLTransformerError = "ERROR"
Variables ¶
var ErrMockSQLTransformer = errors.New("SQL transformer error")
Functions ¶
func SharedTestMain ¶
SharedTestMain starts a postgres container to be used by all tests in a package. Each test then connects to the container and creates a new database. Optional functions that will run after all tests can be added and should return a nil error to indicate they ran successfully. If they return an error all subsequent functions will be skipped.
func TestSchema ¶
func TestSchema() string
TestSchema returns the schema in which migration tests apply migrations. By default, migrations will be applied to the "public" schema.
Types ¶
type MockSQLTransformer ¶
type MockSQLTransformer struct {
// contains filtered or unexported fields
}
func NewMockSQLTransformer ¶
func NewMockSQLTransformer(ts map[string]string) *MockSQLTransformer
NewMockSQLTransformer creates a MockSQLTransformer with the given transformations. The transformations map is a map of input SQL to output SQL. If the output SQL is "ERROR", the transformer will return an error on that input.
func (*MockSQLTransformer) TransformSQL ¶
func (s *MockSQLTransformer) TransformSQL(sql string) (string, error)
TransformSQL transforms the given SQL string according to the transformations provided to the MockSQLTransformer. If the input SQL is not in the transformations map, the input SQL is returned unchanged.