sqlxtest

package
v0.0.0-...-f70f7d2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sqlx.DB

DB connection for tests

Functions

func GetDatabaseNameFromDSN

func GetDatabaseNameFromDSN(dsn string) (string, error)

GetDatabaseNameFromDSN gests the database name from the dsn

Types

type DatabaseSetter

type DatabaseSetter interface {
	ConnectDatabase() (*sqlx.DB, error)

	CreateDatabase() error

	DropDatabase() error
}

DatabaseSetter defines an interface for database configurators

func GetDatabaseSetter

func GetDatabaseSetter(c sqlxdb.Config) (DatabaseSetter, error)

GetDatabaseSetter gets a database setter for the driver on c (sqlxdb.Config)

type Postgres

type Postgres struct {
	TestDB
}

Postgres represents a test database for postgres

func NewPostgres

func NewPostgres(c sqlxdb.Config) (Postgres, error)

NewPostgres creates a Postgres instance

func (Postgres) ConnectDatabase

func (p Postgres) ConnectDatabase() (*sqlx.DB, error)

ConnectDatabase - Implements DatabaseSetter

func (Postgres) CreateDatabase

func (p Postgres) CreateDatabase() error

CreateDatabase - Implements DatabaseSetter

func (Postgres) DropDatabase

func (p Postgres) DropDatabase() error

DropDatabase - Implements DatabaseSetter

type Setup

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

Setup represents the test setup

func NewSetup

func NewSetup(dbConfig sqlxdb.Config) (Setup, error)

NewSetup creates a Setup instance

func (Setup) Destroy

func (s Setup) Destroy() error

Destroy clears all after the test setup

func (Setup) Run

func (s Setup) Run() error

Run runs the test setup

type TestDB

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

TestDB represents a test database

func NewTestDB

func NewTestDB(c sqlxdb.Config) (TestDB, error)

NewTestDB creates a TestDB instance

Jump to

Keyboard shortcuts

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