dbtest

package
v0.0.0-...-2e41b90 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Dialect string
	DSN     string
	// contains filtered or unexported fields
}

DB represents an ephemeral database that starts blank and can be used to run tests against.

func Postgres

func Postgres(t testing.TB) *DB

Postgres provisions a new, blank database with a random name on the localhost of the running process. It assumes that you have postgres running on the default port, have the command line postgres tools installed, and that the current user has access to the server. It panics on the event of a failure.

func (*DB) Close

func (db *DB) Close()

Close closes and deletes the database represented by `db`

func (*DB) Load

func (db *DB) Load(sql string) *DB

Load executes all of the statements in the provided sql script against the test database, panicking if any fail. The receiver is returned allowing for chain-style calling within your test functions.

func (*DB) Open

func (db *DB) Open() *sqlx.DB

Open opens a sqlx connection to the db.

func (*DB) Version

func (db *DB) Version() (major int)

Jump to

Keyboard shortcuts

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