Documentation
¶
Overview ¶
Package postgres provides opt-in PostgreSQL acceptance helpers. Callers supply only their isolated test database. Passing tests remove only their own schemas; failed tests retain them for inspection. No helper resets or drops a database.
Index ¶
Constants ¶
const ( URLVariable = "FOUNDRY_TEST_POSTGRES_URL" RequiredVariable = "FOUNDRY_TEST_POSTGRES_REQUIRED" KeepSchemasVariable = "FOUNDRY_TEST_KEEP_SCHEMAS" )
Variables ¶
This section is empty.
Functions ¶
func Config ¶
Config reads the explicitly opted-in URL. Ordinary test runs skip without it; the required acceptance command fails if it is missing. Errors omit credentials.
func KeepSchemas ¶ added in v0.7.0
KeepSchemas reports whether test-owned PostgreSQL artifacts must be retained. Call it during cleanup so subtest and already-run cleanup failures are included. A cleanup registered before the namespace runs after its drop and cannot retain it.
func Namespace ¶
Namespace creates a unique schema in the caller's isolated test database. The returned identifier contains only safe ASCII letters, digits and underscores. Cleanup removes only this schema when the test passes and KeepSchemas is false. The caller owns db and its closure. Register application cleanup later so LIFO cleanup shuts it down before schema cleanup.
func Open ¶
Open owns one test pool and registers bounded cleanup immediately. Optional adjustments operate on this test's independent settings before construction.
func PrepareNamespace ¶ added in v0.7.0
PrepareNamespace reserves a generated name and registers cleanup before any application or pool cleanup. Call create once, with a pool in the configured test database, when setup is ready to create the schema. Until then cleanup owns nothing. This permits assertions that startup does not create schemas.
Types ¶
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope is one owned namespace in the explicitly opted-in test database. Configuration is immutable; each opened pool is independent and bounded.
func Isolate ¶
Isolate allocates only a fresh schema and removes it after a passing test, unless KeepSchemas is true. The administration pool closes before this returns. Later pool/application cleanups run first in testing's LIFO cleanup order.
func (*Scope) Config ¶
Config returns a caller-owned typed configuration for this owned scope. Scope creation uses the explicit URL, so no mutable TLS pointer is shared.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package application binds test-owned PostgreSQL scopes to production application settings.
|
Package application binds test-owned PostgreSQL scopes to production application settings. |