testutil

package
v0.0.1-0...-3e036b1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2018 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestDatabase

func CreateTestDatabase(dbPath string, migrationFunctions []func(*gorm.DB) error, fixtureFiles []string) (*gorm.DB, error)

CreateTestDatabase recreates the test database and runs migrations and fixtures as passed in, returning a pointer to the database

func CreateTestDatabasePostgres

func CreateTestDatabasePostgres(dbHost, dbUser, dbName string, migrationFunctions []func(*gorm.DB) error, fixtureFiles []string) (*gorm.DB, error)

CreateTestDatabasePostgres is similar to CreateTestDatabase but it uses Postgres instead of sqlite, this is needed for testing packages that rely on some Postgres specifuc features (such as table inheritance)

func TestEmptyResponse

func TestEmptyResponse(t *testing.T, w *httptest.ResponseRecorder)

TestEmptyResponse tests an empty 204 response

func TestErrorExpectedResponse

func TestErrorExpectedResponse(t *testing.T, router *mux.Router, method, url, route string, data io.Reader, accessToken, msg string, code int, assertExpectations func())

TestErrorExpectedResponse is the generic test code for testing for a bad response

func TestGetErrorExpectedResponse

func TestGetErrorExpectedResponse(t *testing.T, router *mux.Router, url, route, accessToken, msg string, code int, assertExpectations func())

TestGetErrorExpectedResponse ...

func TestListValidResponse

func TestListValidResponse(t *testing.T, router *mux.Router, path, entity, accessToken string, items []interface{}, assertExpectations func())

TestListValidResponse ...

func TestListValidResponseWithParams

func TestListValidResponseWithParams(t *testing.T, router *mux.Router, path, entity, accessToken string, items []interface{}, assertExpectations func(), params map[string]string)

TestListValidResponseWithParams tests a list endpoint for a valid response with default settings

func TestPostErrorExpectedResponse

func TestPostErrorExpectedResponse(t *testing.T, router *mux.Router, url, route string, data io.Reader, accessToken, msg string, code int, assertExpectations func())

TestPostErrorExpectedResponse ...

func TestPutErrorExpectedResponse

func TestPutErrorExpectedResponse(t *testing.T, router *mux.Router, url, route string, data io.Reader, accessToken, msg string, code int, assertExpectations func())

TestPutErrorExpectedResponse ...

func TestResponseBody

func TestResponseBody(t *testing.T, w *httptest.ResponseRecorder, expected string)

TestResponseBody tests response body is equal to expected string

func TestResponseForError

func TestResponseForError(t *testing.T, w *httptest.ResponseRecorder, msg string, code int)

TestResponseForError tests a response w to see if it returned an error msg with http code

func TestResponseObject

func TestResponseObject(t *testing.T, w *httptest.ResponseRecorder, expected interface{}, code int)

TestResponseObject tests response body is equal to expected object in JSON form

Types

This section is empty.

Jump to

Keyboard shortcuts

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