Documentation
¶
Overview ¶
Package pgtest provisions disposable keyword-profile schemas on the CONTENTKIT_TEST_URL Postgres for integration tests.
Index ¶
- func EmptySchema(t testing.TB, ctx context.Context, pool *pgxpool.Pool) string
- func EnsureExtensions(t testing.TB, ctx context.Context, pool *pgxpool.Pool)
- func MediaWorkerRole(t testing.TB, ctx context.Context, admin *pgxpool.Pool, schema string, ...) string
- func Pool(t testing.TB, mutate func(*pgxpool.Config)) *pgxpool.Pool
- func Schema(t testing.TB, ctx context.Context, pool *pgxpool.Pool) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmptySchema ¶
EmptySchema creates a disposable schema (dropped on cleanup, its migratekit ledger rows included) for a test that applies a lineage itself.
func EnsureExtensions ¶
EnsureExtensions installs pg_trgm and PGroonga once in public under an advisory lock (CREATE EXTENSION IF NOT EXISTS is not concurrency-safe).
func MediaWorkerRole ¶ added in v0.58.0
func MediaWorkerRole(t testing.TB, ctx context.Context, admin *pgxpool.Pool, schema string, hostSchemas ...string) string
MediaWorkerRole creates a login with exactly the grants production gives a host's media worker (doujins-gitops bind-roles: database CONNECT and CREATE, USAGE and CREATE on its schema, DML on its tables and sequences, USAGE on public and the host schemas) and returns its DSN. The role is dropped on cleanup.
func Schema ¶
Schema creates a disposable schema, applies migrations.Postgres into it the way a host's migrate step does, and drops it on cleanup. The extensions are installed once in public: a schema drop must never take them away from a test running in another package, and CREATE EXTENSION IF NOT EXISTS is not concurrency-safe, so the first install is serialized.
Types ¶
This section is empty.