testutil

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminPool

func AdminPool(t *testing.T) *sql.DB

AdminPool opens the owner-role connection — the same role that runs migrations. For tests that must perform DDL, e.g. replaying a shipped migration's data transform against a seeded pre-migration shape (the app role can't drop/recreate indexes it doesn't own).

func CreateTestTenant

func CreateTestTenant(t *testing.T, db *postgres.DB, name string) string

CreateTestTenant inserts a tenant via the app connection (bypass RLS). Since tenants table has no RLS, this works directly.

func SetupTestDB

func SetupTestDB(t *testing.T) *postgres.DB

func TestCtx

func TestCtx() context.Context

TestCtx returns a context with livemode pinned to false (test mode) — matching the partition every integration test fixture inserts against. Tests that go through the auth middleware in production would inherit livemode from the API key; tests that hit stores or services directly need to pin it explicitly, otherwise BeginTx trips the strict-mode panic ("TxTenant opened without ctx livemode") and silently routes to live in non-strict builds.

Default: livemode=false (test). For live-mode integration tests, wrap context.Background() with postgres.WithLivemode(ctx, true) directly — those are rare enough not to warrant a separate helper.

Types

This section is empty.

Jump to

Keyboard shortcuts

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