v0.1.1 Latest Latest

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

Go to latest
Published: May 9, 2020 License: MIT Imports: 8 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type TestHelper

type TestHelper struct {

TestHelper wraps the testing object

func New

func New(t *testing.T) *TestHelper

New is the factory function to generate the struct

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

Jump to

Keyboard shortcuts

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