Documentation ¶
Index ¶
- type TestHelper
- func (h *TestHelper) CreateServer(path string, response string) (*httptest.Server, func())
- func (h *TestHelper) CreateServerWithError(path string, response string, errorCode int) (*httptest.Server, func())
- func (h *TestHelper) CreateServerWithHandler(path string, response string, handler func(http.ResponseWriter, *http.Request)) (*httptest.Server, func())
- func (h *TestHelper) GetJSON(obj interface{}) string
- func (h *TestHelper) GetObject(data string, dataType interface{}) interface{}
- func (h *TestHelper) LoadData(filename string) string
- func (h *TestHelper) ReadResponse(resp http.Response) string
- func (h *TestHelper) SetOSEnvVar(name, value string) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestHelper ¶
TestHelper wraps the testing object
func (*TestHelper) CreateServer ¶
func (h *TestHelper) CreateServer(path string, response string) (*httptest.Server, func())
CreateServer will initiate a test server and return the given response for the URL
func (*TestHelper) CreateServerWithError ¶
func (h *TestHelper) CreateServerWithError(path string, response string, errorCode int) (*httptest.Server, func())
CreateServerWithError will create a test server and return the HTTP error code for the URL
func (*TestHelper) CreateServerWithHandler ¶
func (h *TestHelper) CreateServerWithHandler(path string, response string, handler func(http.ResponseWriter, *http.Request)) (*httptest.Server, func())
CreateServerWithHandler will initiate a test server and return the given response for the URL
func (*TestHelper) GetJSON ¶
func (h *TestHelper) GetJSON(obj interface{}) string
GetJSON returns the JSON representation of the struct
func (*TestHelper) GetObject ¶
func (h *TestHelper) GetObject(data string, dataType interface{}) interface{}
GetObject converts the string data into an object
func (*TestHelper) LoadData ¶
func (h *TestHelper) LoadData(filename string) string
LoadData reads the test data file under `testdata` folder
func (*TestHelper) ReadResponse ¶
func (h *TestHelper) ReadResponse(resp http.Response) string
ReadResponse converts the data in HTTP response to a string
func (*TestHelper) SetOSEnvVar ¶
func (h *TestHelper) SetOSEnvVar(name, value string) func()
SetOSEnvVar sets a value and then cleans it up after testing
Click to show internal directories.
Click to hide internal directories.