sqitchdb

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

Overview

Package sqitchdb allow "unit testing" of (postgres) database whose schema is controlled by sqitch

Calling New will start a container running postgres with the latest schema/data loaded. The Conn method return a connection to this database (sql.DB) that can be used for testing. Close will shutdown the container.

Reset will return an open database to the state that it was initially. So the idea is that it in a TestMain (or something like that) the database would start and then individual tests can start by calling Reset

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB represent a running database

func New

func New(tb testing.TB, dir string, ver string, logger func(string)) (*DB, error)

New start a container and load the schema. dir is the directory that contain the sqlitch schema ver is the postgres version if tb is not nil it is used to fail tests (so that New does not return error) as well as a default for the logger function

func (*DB) Close

func (d *DB) Close() error

Close shut down the contaienr

func (*DB) Conn

func (d *DB) Conn() *sql.DB

Conn return a database connection to be used in testing

func (*DB) Reset

func (d *DB) Reset() (*sql.DB, error)

Reset the database to its original state

Jump to

Keyboard shortcuts

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