Version: v0.0.0-...-44bef96 Latest Latest

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

Go to latest
Published: May 19, 2017 License: MIT Imports: 8 Imported by: 0




This section is empty.


This section is empty.


func SetupDB

func SetupDB(t *testing.T) *service.Database

SetupDB initializes a test database, performing all migrations.


type Env

type Env struct {
	T          *testing.T
	DB         *service.Database
	Server     *service.Server
	HttpServer *httptest.Server
	Client     service.Client

Env provides access to all services used in tests, like the database, our server, and an HTTP client for performing HTTP requests against the test server.

func SetupEnv

func SetupEnv(t *testing.T) *Env

SetupEnv creates a new test environment, including a clean database and an instance of our HTTP service.

func (*Env) Close

func (env *Env) Close()

Close must be called after each test to ensure the Env is properly destroyed.

func (*Env) ReadContactWithEmail

func (env *Env) ReadContactWithEmail(email string) *service.Contact

ReadContactWithEmail reads a contact from the test database with the given email. Helpers like this make it easy to verify the state of the database as part of a test.

func (*Env) SetupContact

func (env *Env) SetupContact(email string, name string) *service.Contact

SetupContact creates a Contact for use in tests. How it creates the contact is an implementation detail, but it should record an error if the resulting contact would be invalid.

Jump to

Keyboard shortcuts

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