pkgsite: Index | Files

package dbtest

import ""

Package dbtest supports testing with a database.


Package Files


func ConnectAndExecute Uses

func ConnectAndExecute(uri string, dbFunc func(*sql.DB) error) (outerErr error)

ConnectAndExecute connects to the postgres database specified by uri and executes dbFunc, then cleans up the database connection. It returns an error that Is derrors.NotFound if no connection could be made.

func CreateDB Uses

func CreateDB(dbName string) error

CreateDB creates a new database dbName.

func CreateDBIfNotExists Uses

func CreateDBIfNotExists(dbName string) error

CreateDBIfNotExists checks whether the given dbName is an existing database, and creates one if not.

func DBConnURI Uses

func DBConnURI(dbName string) string

DBConnURI generates a postgres connection string in URI format. This is necessary as migrate expects a URI.

func DropDB Uses

func DropDB(dbName string) error

DropDB drops the database named dbName.

type MultiErr Uses

type MultiErr []error

MultiErr can be used to combine one or more errors into a single error.

func (MultiErr) Error Uses

func (m MultiErr) Error() string

Package dbtest imports 10 packages (graph) and is imported by 2 packages. Updated 2021-01-17. Refresh now. Tools for package owners.