pgtest

package
v0.0.0-...-0391e5f Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Postgres

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

Postgres is an mlab container running postgres

func New

func New(tb testing.TB, ver string, log func(string)) (*Postgres, error)

New create a new Postgres object it start a postgress database of the specified version, and allow processes to connect to it

if tb is not null the postgres object is related to this testing object: logs will be sent to it, and New either succeed or fail the test with Fatal, so errors don't need to be tested.

log is optional function to log stderr/stdout of the database, can be nil and then default are used (either tb.Log or stdout)

func (*Postgres) Close

func (p *Postgres) Close() error

Close releases resources connected to the postgres object (in particular kill the container)

func (*Postgres) GetAddressPort

func (p *Postgres) GetAddressPort() (net.IP, int, error)

GetAddressPort return the address and port used to access the DB

func (*Postgres) GetDB

func (p *Postgres) GetDB(name string) (*sql.DB, error)

GetDB get an sql.DB object conected to the postgres with the specified database name

func (*Postgres) IP

func (p *Postgres) IP() (net.IP, error)

IP return the internal IP address of postgress

func (*Postgres) Log

func (p *Postgres) Log(format string, a ...interface{})

Log a string

Jump to

Keyboard shortcuts

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