testing

package
v0.0.0-...-1813979 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAfterCallback

func RegisterAfterCallback(cb func() error)

RegisterAfterCallback registers a callback to be run after the last test

func RunAfterCallbacks

func RunAfterCallbacks()

RunAfterCallbacks executes all registered callbacks

func RunWithDB

func RunWithDB(t *testing.T, testFunc func(*TestDB))

RunWithDB executes testFunc with a prepared test database connection

func RunWithServer

func RunWithServer(t *testing.T, handler func(net.Conn, *coelacanth.Server), testFunc func(*coelacanth.Server, string))

RunWithServer executes testFunc with a prepared server

Types

type TestDB

type TestDB struct {
	coelacanth.DB
	// contains filtered or unexported fields
}

TestDB is a testing database connection. Most calls are proxied to an internal transaction so they can be rolled back after each test.

func (TestDB) Begin

func (db TestDB) Begin() (*sql.Tx, error)

Begin proxies calls to the active transaction

func (TestDB) Close

func (db TestDB) Close() error

Close is a no-op. The connection is only closed at the conclusion of the test suite.

func (TestDB) Exec

func (db TestDB) Exec(query string, args ...interface{}) (sql.Result, error)

Exec proxies calls to the active transaction

func (TestDB) Prepare

func (db TestDB) Prepare(query string) (*sql.Stmt, error)

Prepare proxies calls to the active transaction

func (TestDB) Query

func (db TestDB) Query(query string, args ...interface{}) (*sql.Rows, error)

Query proxies calls to the active transaction

func (TestDB) QueryRow

func (db TestDB) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow proxies calls to the active transaction

Jump to

Keyboard shortcuts

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