Documentation
¶
Overview ¶
Package application binds retained PostgreSQL scopes to production application settings. It stays separate from the lightweight testkit/postgres helpers so low-level packages can use schema isolation without an infrastructure cycle.
Index ¶
- type Application
- type Environment
- func (Environment) Format(s fmt.State, _ rune)
- func (e *Environment) Migrate(ctx context.Context, targets ...infrastructure.MigrationTarget) error
- func (e *Environment) Settings() infrastructure.DatabaseSettings
- func (e *Environment) Start(t testing.TB, app Application, domain ...infrastructure.MigrationTarget) error
- type Selection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface {
Start(context.Context) error
Shutdown(context.Context) error
ShutdownTimeout() time.Duration
Migrations() []infrastructure.MigrationTarget
}
Application is satisfied by *application.App without importing application assembly into a feature helper. Build it from Environment.Settings through application.Settings.WithDatabaseScopes before handing it to Start.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment contains scoped copies of every selected logical connection. It owns migration setup and registers bounded application cleanup through Start.
func Bind ¶
func Bind(settings infrastructure.DatabaseSettings, selections ...Selection) (*Environment, error)
Bind requires every configured connection exactly once. Separate Isolate calls express distinct namespaces; one On call expresses intentional sharing. Test pools use two connections per endpoint and retain the configured global ceiling. This neither mutates original settings nor reconfigures a live pool.
func (*Environment) Migrate ¶
func (e *Environment) Migrate(ctx context.Context, targets ...infrastructure.MigrationTarget) error
Migrate validates all targets first, then applies one registry/history per physical namespace. Each short-lived primary pool closes before the next opens. Successful migrations and data remain committed if a later group fails.
func (*Environment) Settings ¶
func (e *Environment) Settings() infrastructure.DatabaseSettings
Settings returns caller-owned settings; defaults still alias their named pool.
func (*Environment) Start ¶
func (e *Environment) Start(t testing.TB, app Application, domain ...infrastructure.MigrationTarget) error
Start owns cleanup before migration/startup. Framework and explicit domain migrations commit through the ordinary runner before providers start. A failed attempt also shuts down immediately. HTTP/worker lifetimes remain app-owned; register test clients afterward so their cleanup precedes app shutdown.
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection explicitly states which named application connections share a scope. No original deployment endpoint or password survives binding.