Documentation ¶
Overview ¶
Package integration is a helper for running integration tests.
Index ¶
Constants ¶
const ( // EnvPGConnString is the environment variable examined for a DSN for a // pre-existing database engine. If unset, an appropriate database will // attempt to be downloaded and run. EnvPGConnString = "POSTGRES_CONNECTION_STRING" // EnvPGVersion is the environment variable examined for the version of // PostgreSQL used if an embedded binary would be used. EnvPGVersion = `PGVERSION` )
Variables ¶
This section is empty.
Functions ¶
func DBSetup ¶ added in v0.5.0
func DBSetup() func()
DBSetup queues setup and teardown for a postgres engine instance. If the "integration" build tag is not provided, then nothing is done. If the environment variable at EnvPGConnString is populated and the "integration" build tag is provided, then the value of that environment variable is used instead of an embedded postgres binary.
This function is meant to be called from TestMain like so:
func TestMain(m *testing.M) { var c int defer func() { os.Exit(c) }() defer integration.DBSetup()() c = m.Run() }
func NeedDB ¶ added in v0.5.0
NeedDB is like Skip, except that the test will run if the needed binaries have been fetched.
func Skip ¶
Skip will skip the current test or benchmark if this package was built without the "integration" build tag.
This should be used as an annotation at the top of the function, like (*testing.T).Parallel().
func TestThatTouchesNetwork(t *testing.T) { t.Parallel() integration.Skip(t) // ... }
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a handle for connecting to an cleaning up a created database.
func NewDB ¶
NewDB generates a unique database instance for use in concurrent integration tests.
An environment variable maybe use to provide the root connection string used to generate a test specific database.
If no environment variable is specified the root connection string defaults to our local development db connection string DefaultDSN.