Documentation
¶
Index ¶
- Constants
- Variables
- func SharedTestMain(m *testing.M)
- 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 WithMigratorInSchemaAndConnectionToContainer(t *testing.T, schema string, fn func(mig *roll.Roll, db *sql.DB))
- func WithMigratorInSchemaAndConnectionToContainerWithOptions(t *testing.T, 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" FKViolationErrorCode string = "foreign_key_violation" NotNullViolationErrorCode string = "not_null_violation" 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.
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.
func WithConnectionToContainer ¶ added in v0.6.0
func WithMigratorAndConnectionToContainerWithOptions ¶ added in v0.6.0
func WithStateInSchemaAndConnectionToContainer ¶ added in v0.6.0
Types ¶
type MockSQLTransformer ¶ added in v0.6.0
type MockSQLTransformer struct {
// contains filtered or unexported fields
}
func NewMockSQLTransformer ¶ added in v0.6.0
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 ¶ added in v0.6.0
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.