Documentation
¶
Overview ¶
Package testdb provides a shared PostgreSQL test container for integration tests. It starts a single container per test binary (via sync.Once), runs goose migrations, and returns a connection pool ready for use.
Tests should use CreateTestFeature to create uniquely-named features and flags that are automatically cleaned up, enabling parallel test execution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Require ¶
Require starts a PostgreSQL test container (once per binary), runs goose migrations, and returns a fresh connection pool. The pool is closed via tb.Cleanup.
Tables are NOT truncated; use CreateTestFeature to create isolated test fixtures that are cleaned up automatically per test.
Types ¶
type FlagSpec ¶ added in v0.15.0
type FlagSpec struct {
FlagType string // e.g. "BOOL", "STRING", "INT64", "DOUBLE"
}
FlagSpec describes one flag to create within a test feature.
type TestFeature ¶ added in v0.15.0
TestFeature holds the feature_id and flag IDs created for a test.
func CreateTestFeature ¶ added in v0.15.0
CreateTestFeature inserts a uniquely-named feature and its flags into the database. The feature_id is derived from t.Name() plus a sequence number, guaranteeing no collisions even when tests run in parallel.
Cleanup is registered via t.Cleanup to delete the feature, its flags, overrides, and audit log entries when the test finishes.
func (*TestFeature) FlagID ¶ added in v0.15.0
func (f *TestFeature) FlagID(fieldNum int) string
FlagID returns the flag_id for the given field number (1-based). Panics if fieldNum is out of range.