pgtest

package
v1.31.3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pgtest holds shared test-only helpers for pgvector store integration tests (analogous in spirit to stdlib's net/http/httptest: a dedicated test-support package, never imported by production code).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RestoreDSNs

func RestoreDSNs(t *testing.T) (appDSN, adminDSN string)

RestoreDSNs reads the two DSNs an ownership-transfer restore-simulation test needs and skips the test if either is unset:

  • DATABASE_URL: the role the store under test connects as (the "app" role).
  • OWNERSHIP_TEST_ADMIN_DSN: a different, already-privileged role that stands in for the pg_restore-time role and pre-creates the table.

func SimulateRestore

func SimulateRestore(ctx context.Context, t *testing.T, adminDSN, schemaSQL, table string) (adminPool *pgxpool.Pool, ownerBefore string)

SimulateRestore connects as adminDSN, refuses to run against anything but an obvious throwaway test/CI database (guards against DROPping a real table if OWNERSHIP_TEST_ADMIN_DSN is ever pointed at a live DB), then (re)creates table via schemaSQL under the admin role — mirroring a superuser pg_restore that leaves the table owned by the restoring role.

Returns the admin pool (closed automatically via t.Cleanup) and the table's owner immediately after creation, for the caller to compare against the owner after exercising the store's init path.

func TableOwner

func TableOwner(ctx context.Context, t *testing.T, pool *pgxpool.Pool, table string) string

TableOwner returns table's current owner per pg_tables.

Types

This section is empty.

Jump to

Keyboard shortcuts

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