util

package
v0.0.0-...-ed100b9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package util provides test utilities and helper functions for database testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSearchPathToConnString

func AddSearchPathToConnString(connStr, schemaName string) string

AddSearchPathToConnString appends search_path parameter to a PostgreSQL connection string. This ensures all connections in the pool use the specified schema. Includes "public" so that extension types (e.g. pgvector's "vector") installed in the public schema remain visible.

func GenerateSchemaName

func GenerateSchemaName(t *testing.T) string

GenerateSchemaName creates a unique, PostgreSQL-safe schema name for the test. Format: test_<sanitized_test_name>_<random_hex>

func GetBaseConnectionString

func GetBaseConnectionString(t *testing.T) string

GetBaseConnectionString returns the base PostgreSQL connection string (without schema search_path). Used by integration tests that need a raw connection string for dedicated connections, e.g. NotifyListener's pgx.Conn.

func SetupTestDatabase

func SetupTestDatabase(t *testing.T) (*ent.Client, *stdsql.DB)

SetupTestDatabase creates a test database and returns the raw components. Both CI and local dev use per-test schemas for isolation and scalability. - CI: Connects to external PostgreSQL service container - Local: Uses a shared testcontainer (started once per package) Returns the ent client and database connection for wrapping by the caller.

Types

This section is empty.

Jump to

Keyboard shortcuts

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