testutil

package
v0.0.0-...-9e2453e Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2019 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 CreateTestDatabaseMysql

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

CreateTestDatabaseMysql is similar to CreateTestDatabase but it uses Mysql instead of sqlite, this is needed for testing packages that rely on some Mysql 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 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, 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 string, data io.Reader, accessToken, msg string, code int, assertExpectations func())

TestPostErrorExpectedResponse ...

func TestPutErrorExpectedResponse

func TestPutErrorExpectedResponse(t *testing.T, router *mux.Router, url 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