postgrestest

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: LGPL-3.0 Imports: 7 Imported by: 0

README

Simple support for Go testing with a live Postgres database
----

This package makes it straightforward to write tests that connect
to a fresh Postgres database created for the tests.

Documentation

Overview

Package postgrestest provides a package intended for running tests which require a Postgres backend.

Index

Constants

This section is empty.

Variables

View Source
var ErrDisabled = errgo.New("postgres testing is disabled")

ErrDisabled is returned by New when postgres testing has been explicitly disabled.

Functions

func PgTestDisable

func PgTestDisable() bool

PgTestDisable returns whether Postgres should be disabled based on the PGTESTDISABLE environment variable.

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB holds a connection to a Postgres database.

func New

func New() (*DB, error)

func (*DB) Close

func (pg *DB) Close() error

Close removes the test database and closes the database connection. This method should not be called from multiple goroutines.

func (*DB) TransactionName added in v1.5.0

func (pg *DB) TransactionName() string

TransactionName returns the test transaction name.

Jump to

Keyboard shortcuts

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