Documentation
¶
Overview ¶
Package postgrestest provides real PostgreSQL containers for integration tests. It never substitutes a fake for PostgreSQL semantics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Image string
Database string
Username string
Password string
// HostPort optionally binds PostgreSQL to a stable loopback port. It is
// useful for stop/start tests whose client endpoint must not move.
HostPort string
// CleanupTimeout bounds container termination even when the setup context
// has already been canceled.
CleanupTimeout time.Duration
Setup func(context.Context, string) error
}
Config controls an isolated PostgreSQL container. Setup runs exactly once after PostgreSQL is accepting connections and receives its complete DSN.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database owns a PostgreSQL test container and its connection string.
func Start ¶
Start creates a PostgreSQL container, waits for readiness, obtains a DSN, and invokes the optional deterministic setup hook.
func (*Database) Close ¶
Close terminates the container. Failed termination may be retried; after a successful termination, later calls return nil without repeating it.
func (*Database) Container ¶
func (d *Database) Container() *postgres.PostgresContainer
Container exposes the native testcontainers PostgreSQL container.