postgresqltestenv

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package postgresqltestenv centralizes environment variables and destructive PostgreSQL test safety checks. Library analysis code must never import this package or execute mutations.

Index

Constants

View Source
const (
	// IntegrationDSNEnv is the canonical DSN variable for optional PostgreSQL
	// integration tests and test utilities.
	IntegrationDSNEnv = "SQL_GUNYU_POSTGRES_TEST_DSN"
	// AllowRemoteDDLEnv is the explicit opt-in for destructive remote tests.
	AllowRemoteDDLEnv = "SQL_GUNYU_POSTGRES_ALLOW_REMOTE_DDL"
	// ExpectedMajorEnv pins a connected test job to PostgreSQL 16 or 17.
	ExpectedMajorEnv = "SQL_GUNYU_POSTGRES_EXPECT_MAJOR"
)

Variables

This section is empty.

Functions

func AllowRemoteDDL

func AllowRemoteDDL() bool

AllowRemoteDDL reports the separate, explicit remote-mutation opt-in.

func IntegrationDSN

func IntegrationDSN() (dsn, source string)

IntegrationDSN returns the configured PostgreSQL test DSN.

func ValidateManagedObjectName

func ValidateManagedObjectName(name string) error

ValidateManagedObjectName restricts cleanup to runner-owned objects.

func ValidateMutationTarget

func ValidateMutationTarget(dsn, schema string, allowRemote bool) error

ValidateMutationTarget proves that a test DSN and schema stay within the explicitly selected disposable boundary. It never returns or logs the DSN.

func ValidateServerMajor

func ValidateServerMajor(actual int) error

ValidateServerMajor prevents one PostgreSQL major from satisfying another fixed-image job. When ExpectedMajorEnv is unset it still rejects unsupported server majors, preserving direct opt-in test compatibility.

Types

type RecordingDB

type RecordingDB struct {
	DB   *sql.DB
	Mock sqlmock.Sqlmock
	// contains filtered or unexported fields
}

RecordingDB guards offline PostgreSQL fixture IO, including errors swallowed by a production fallback. DB is backed by sqlmock and never opens a network.

func NewRecordingDB

func NewRecordingDB(t testing.TB, allowed ...error) *RecordingDB

NewRecordingDB returns a query-only fixture with explicit modeled faults.

func (*RecordingDB) Calls

func (r *RecordingDB) Calls() int

Calls counts all attempted statements, including modeled failures.

func (*RecordingDB) Verify

func (r *RecordingDB) Verify() error

Verify rejects unexpected calls even if the caller ignored their errors.

Jump to

Keyboard shortcuts

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