Documentation ¶
Index ¶
- func CreateTestDatabase(dbPath string, migrationFunctions []func(*gorm.DB) error, ...) (*gorm.DB, error)
- func CreateTestDatabasePostgres(dbHost, dbUser, dbName string, migrationFunctions []func(*gorm.DB) error, ...) (*gorm.DB, error)
- func TestEmptyResponse(t *testing.T, w *httptest.ResponseRecorder)
- func TestErrorExpectedResponse(t *testing.T, router *mux.Router, method, url string, data io.Reader, ...)
- func TestGetErrorExpectedResponse(t *testing.T, router *mux.Router, url, accessToken, msg string, code int, ...)
- func TestListValidResponse(t *testing.T, router *mux.Router, path, entity, accessToken string, ...)
- func TestListValidResponseWithParams(t *testing.T, router *mux.Router, path, entity, accessToken string, ...)
- func TestPostErrorExpectedResponse(t *testing.T, router *mux.Router, url string, data io.Reader, ...)
- func TestPutErrorExpectedResponse(t *testing.T, router *mux.Router, url string, data io.Reader, ...)
- func TestResponseBody(t *testing.T, w *httptest.ResponseRecorder, expected string)
- func TestResponseForError(t *testing.T, w *httptest.ResponseRecorder, msg string, code int)
- func TestResponseObject(t *testing.T, w *httptest.ResponseRecorder, expected interface{}, code int)
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 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 ¶
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.