abcdatabase

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoMigrations occurs if no migration files can be found on disk
	ErrNoMigrations = errors.New("no migrations found")
)

Functions

func ExecuteScript

func ExecuteScript(cfg abcconfig.DBConfig, script []byte) error

ExecuteScript executes the passed in SQL script against the passed in db

func GetConnStr

func GetConnStr(cfg abcconfig.DBConfig) (string, error)

GetConnStr returns a connection string for the database software used

func IsMigrated

func IsMigrated(cfg abcconfig.DBConfig) (bool, int64, error)

IsMigrated returns true if the database is migrated to the latest migration in the db/migrations folder. It also returns the current database migration version number.

func SetupTestSuite

func SetupTestSuite(cfg abcconfig.DBConfig, testdata TestdataFunc) (int, error)

SetupTestSuite executes the migrations "up" against the passed in database and also inserts the test data defined in testdata.sql and returns the number of migrations run.

SetupTestSuite is used primarily as a testing helper, and is called in controllers_test.go to set up the database state for the controller tests.

Types

type TestdataFunc

type TestdataFunc func(driver, conn string) error

TestdataFunc is the function signature for the sql testdata function that performs database operations once the test suite is initialized with migrations and the sql testdata file.

Jump to

Keyboard shortcuts

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