Versions in this module Expand all Collapse all v0 v0.1.0 Oct 22, 2026 Changes in this version + const KeepOnFailureEnv + const MaxDBPrefixLength + var ErrNilProvider = errors.New("provider cannot be nil") + var ErrNoMigrator = errors.New("no migrator configured") + var ErrPrefixTooLong = errors.New("database prefix too long: would exceed database identifier limit") + var ErrTemplatesNotSupported = errors.New("templates are not supported") + func ContextOf(t testing.TB) context.Context + func NewDatabaseName(prefix string) (string, error) + func RegisterCleanup(t testing.TB, db *TestDatabase) + func ResolveAdminDSN(cfg Config, defaultDSN string, providerEnv ...string) string + func RunConfiguredMigrations(t testing.TB, db *TestDatabase, callerName string) + type Config struct + AdminDSNOverride string + DBPrefix string + KeepOnFailure bool + Migrator Migrator + TemplateName string + Verbose bool + func DefaultConfig() Config + type DBInitializer interface + InitializeTestDatabase func(ctx context.Context, dsn string) (any, error) + type Error struct + Err error + Op string + func (e *Error) Error() string + func (e *Error) Unwrap() error + type InspectCommander interface + InspectCommand func(dsn string) string + type Migrator interface + Migrate func(ctx context.Context, dsn string) error + type MigratorFunc func(ctx context.Context, dsn string) error + func (f MigratorFunc) Migrate(ctx context.Context, dsn string) error + type Option func(*Config) + func WithAdminDSN(dsn string) Option + func WithDBPrefix(prefix string) Option + func WithKeepOnFailure() Option + func WithMigrator(m Migrator) Option + func WithTemplate(name string) Option + func WithVerbose() Option + type Provider interface + BuildDSN func(dbName string) (string, error) + Cleanup func(ctx context.Context) error + CreateDatabase func(ctx context.Context, name string) error + DropDatabase func(ctx context.Context, name string) error + Initialize func(ctx context.Context, cfg Config) error + ResolvedAdminDSN func() string + TerminateConnections func(ctx context.Context, name string) error + type TemplateProvider interface + CreateDatabaseFromTemplate func(ctx context.Context, requestedName, templateName string) (actualName string, err error) + TemplateExists func(ctx context.Context, name string) (bool, error) + type TestDatabase struct + func New(t testing.TB, provider Provider, initializer DBInitializer, opts ...Option) (*TestDatabase, error) + func (td *TestDatabase) Close() error + func (td *TestDatabase) Config() Config + func (td *TestDatabase) DSN() string + func (td *TestDatabase) Entity() any + func (td *TestDatabase) Keep() + func (td *TestDatabase) Name() string + func (td *TestDatabase) RunMigrations(ctx context.Context) error