integration

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package integration is a helper for running integration tests.

Index

Constants

View Source
const (
	DefaultDSN      = `host=localhost port=5434 user=claircore dbname=claircore sslmode=disable` // connection string for our local development. see docker-compose.yaml at root
	EnvPGConnString = "POSTGRES_CONNECTION_STRING"
)

DefaultDSN is a dsn for database server usually set up by the project's Makefile.

Variables

This section is empty.

Functions

func Skip

func Skip(t testing.TB)

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

func NewDB(ctx context.Context, t testing.TB) (*DB, error)

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.

func (*DB) Close

func (db *DB) Close(ctx context.Context, t testing.TB)

Close tears down the created database.

func (*DB) Config

func (db *DB) Config() *pgxpool.Config

Config returns a pgxpool.Config for the created database.

Jump to

Keyboard shortcuts

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