pgtest

package module
v1.99.6 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 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 = "16.1.0"
)
View Source
var Verbose bool

Functions

func NoSetup

func NoSetup(Conn) error

func WithDatabase

func WithDatabase(ctx context.Context, t *testing.T, setup SetupFunc, test TestFunc)

Types

type Config added in v1.99.0

type Config struct {
	Binary   string
	Snapshot string
	Workdir  string
}

func Install added in v1.99.4

func Install() (Config, error)

type Conn added in v1.99.0

type Conn struct {
	*sql.DB
	URL string
}

type Instance added in v1.99.0

type Instance struct {
	URL string
	// contains filtered or unexported fields
}

func (*Instance) Close added in v1.99.0

func (inst *Instance) Close() error

type Logger

type Logger interface {
	Log(...interface{})
}

type Process added in v1.99.0

type Process struct {
	// contains filtered or unexported fields
}

func Start added in v1.99.0

func Start(config Config) (*Process, error)

func (*Process) Child added in v1.99.0

func (proc *Process) Child(ctx context.Context) (*Instance, error)

func (*Process) Close added in v1.99.0

func (proc *Process) Close() error

type SetupFunc

type SetupFunc func(db Conn) error

type TestFunc

type TestFunc func(db Conn)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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