pgtest

package
v0.58.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pgtest provisions disposable keyword-profile schemas on the CONTENTKIT_TEST_URL Postgres for integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptySchema

func EmptySchema(t testing.TB, ctx context.Context, pool *pgxpool.Pool) string

EmptySchema creates a disposable schema (dropped on cleanup, its migratekit ledger rows included) for a test that applies a lineage itself.

func EnsureExtensions

func EnsureExtensions(t testing.TB, ctx context.Context, pool *pgxpool.Pool)

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 Pool

func Pool(t testing.TB, mutate func(*pgxpool.Config)) *pgxpool.Pool

Pool connects to CONTENTKIT_TEST_URL or skips; mutate may adjust the config.

func Schema

func Schema(t testing.TB, ctx context.Context, pool *pgxpool.Pool) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL