Documentation
¶
Overview ¶
Package mock provides an in-memory mock driver for testing Queen without a real database.
IMPORTANT: Mock driver only works with Go function migrations (UpFunc/DownFunc). SQL migrations (UpSQL/DownSQL) require a real database connection and will panic when used with the mock driver.
For testing SQL migrations, use a real database (e.g., postgres in Docker) or use the testcontainers library.
Index ¶
- type Driver
- func (d *Driver) AppliedCount() int
- func (d *Driver) Close() error
- func (d *Driver) Exec(ctx context.Context, fn func(*sql.Tx) error) error
- func (d *Driver) GetApplied(ctx context.Context) ([]queen.Applied, error)
- func (d *Driver) HasVersion(version string) bool
- func (d *Driver) Init(ctx context.Context) error
- func (d *Driver) IsLocked() bool
- func (d *Driver) Lock(ctx context.Context, timeout time.Duration) error
- func (d *Driver) Record(ctx context.Context, m *queen.Migration) error
- func (d *Driver) Remove(ctx context.Context, version string) error
- func (d *Driver) Reset()
- func (d *Driver) SetInitError(err error)
- func (d *Driver) SetLockError(err error)
- func (d *Driver) SetRecordError(err error)
- func (d *Driver) Unlock(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is an in-memory mock implementation of queen.Driver for testing.
func (*Driver) AppliedCount ¶
AppliedCount returns the number of applied migrations (for testing).
func (*Driver) GetApplied ¶
GetApplied returns all applied migrations.
func (*Driver) HasVersion ¶
HasVersion returns whether a specific version has been applied (for testing).
func (*Driver) SetInitError ¶
SetInitError makes Init return the specified error.
func (*Driver) SetLockError ¶
SetLockError makes Lock return the specified error.
func (*Driver) SetRecordError ¶
SetRecordError makes Record return the specified error.