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 ¶
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 ¶
ValidateManagedObjectName restricts cleanup to runner-owned objects.
func ValidateMutationTarget ¶
ValidateMutationTarget proves that a test DSN and schema stay within the explicitly selected disposable boundary. It never returns or logs the DSN.
func ValidateServerMajor ¶
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.