testpostgres

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package testpostgres runs a real Postgres for tests from embedded-postgres' downloaded binaries, so the Postgres-backed tests need no docker daemon.

Index

Constants

View Source
const RequireEnv = "STEPS_REQUIRE_POSTGRES"

RequireEnv names the variable that, set to 1, turns unobtainable binaries from a skip into a failure, for a run that must not pass by not testing Postgres.

Variables

View Source
var ErrUnavailable = errors.New("postgres binaries unavailable")

ErrUnavailable means the server's binaries could not be had (the first run on a machine downloads them), which a caller treats as a skip. Anything else Start returns is a failure.

View Source
var Fast = map[string]string{
	"max_connections":    "500",
	"fsync":              "off",
	"synchronous_commit": "off",
	"full_page_writes":   "off",
}

Fast trades durability for speed, for tests whose database dies with the run. A measurement leaves it out: Postgres' own defaults are what an operator gets.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Host is "127.0.0.1:port".
	Host     string
	Password string
	// contains filtered or unexported fields
}

Server is a running Postgres reachable on loopback only, with a password nothing else knows.

func Start

func Start(settings map[string]string) (*Server, error)

Start sweeps first because a run killed outright never reached its own Stop. With STEPS_REQUIRE_POSTGRES=1 unobtainable binaries are a failure rather than an ErrUnavailable skip.

func (*Server) Stop

func (s *Server) Stop()

Stop is nil-safe so a deferred Stop works after a start that was skipped.

func (*Server) URL

func (s *Server) URL() string

URL is the superuser's URL on the "postgres" database, password included.

Jump to

Keyboard shortcuts

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