pgtest

package module
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 22 Imported by: 0

README

pgtest

Start a local postgres for testing in your go tests.

FAQ

Mac
FATAL: could not create shared memory segment: No space left on device

Create the file /Library/LaunchDaemons/memory.plist Add the content

<plist version="1.0">
<dict>
 <key>Label</key>
 <string>shmemsetup</string>
 <key>UserName</key>
 <string>root</string>
 <key>GroupName</key>
 <string>wheel</string>
 <key>ProgramArguments</key>
 <array>
  <string>/usr/sbin/sysctl</string>
  <string>-w</string>
  <string>kern.sysv.shmmax=3221225472</string>
  <string>kern.sysv.shmmni=4096</string>
  <string>kern.sysv.shmseg=4096</string>
  <string>kern.sysv.shmall=33554432</string>
 </array>
 <key>KeepAlive</key>
 <false/>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>

Then run

sudo chown root:wheel /Library/LaunchDaemons/memory.plist
sudo launchctl load -w /Library/LaunchDaemons/memory.plist

Then reboot

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Root    = os.ExpandEnv("${HOME}/.pgtest")
	Version = "18.3.0"
)

Functions

func Connect

func Connect(t testing.TB) *sql.DB

func ConnectWithSetup

func ConnectWithSetup(t testing.TB, setup SetupFunc) *sql.DB

func ConnectionString

func ConnectionString(t testing.TB) string

ConnectionString creates a new postgres instance & database and returns the connection string to this database as soon as it is reachable.

Types

type Config

type Config struct {
	Binary   string
	Snapshot string
	Workdir  string
}

func Install

func Install(t testing.TB) (Config, error)

Install installs the default postgres version. This respects the PGTEST_VERSION environment variable

type SetupFunc

type SetupFunc func(db *sql.DB) error

Jump to

Keyboard shortcuts

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