Documentation
¶
Overview ¶
Package pgkit gives each test its own pristine, migrated Postgres database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FSMigrator ¶
FSMigrator adapts an embedded migration directory plus the project's own migration runner to pgtestdb.Migrator.
pgtestdb's bundled adapters take migration source URLs. Projects here embed their migrations with go:embed and run them through a function taking a DSN, so neither shipped adapter fits.
Types ¶
type Config ¶
type Config struct {
// Migrator is required. Use FSMigrator.
Migrator pgtestdb.Migrator
// ComposeDSN is tried when DSNEnv is unset. Defaults to the docker-compose service
// on port 55433.
ComposeDSN string
// DSNEnv names the environment variable checked first. Defaults to
// TESTKIT_POSTGRES_DSN.
DSNEnv string
// Image is the fallback container image. Defaults to postgres:16-alpine.
Image string
// ReachableTimeout budgets the ComposeDSN login probe. Defaults to 3s. Raise it on
// a slow or heavily loaded machine, where an over-tight budget quietly costs a
// container boot instead of reusing a healthy compose server.
ReachableTimeout time.Duration
}
Config declares how to reach a Postgres server and how to migrate it.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server resolves one Postgres server per test-binary process and hands out a pristine database per test.
func New ¶
New returns a Server. Call it once at package level; resolution is lazy and happens on the first Fresh call.