Documentation ¶
Index ¶
- func AssertHandlerFunc(t *testing.T, request *http.Request, ...) error
- func AssertResponseOfRequestCall(t *testing.T, request *http.Request, ...) error
- func AssertResponseStatusOfRequestCall(t *testing.T, request *http.Request, expectedResponseStatus int) error
- func CreateIncomingErrorReadingBodyRequest(method, path string, header Header) *http.Request
- func CreateIncomingRequest(method, path string, header Header, body string) *http.Request
- func CreateOutgoingRequest(t *testing.T, method, path string, header Header, body string) *http.Request
- func RandString(n int) string
- func RunAndCheckCoverage(testPackage string, m *testing.M, treshold float64) int
- func StartServing(router *mux.Router)
- func StopServing()
- type Header
- type ReaderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertHandlerFunc ¶
func AssertHandlerFunc(t *testing.T, request *http.Request, handlerFunc func(http.ResponseWriter, *http.Request), assertResponse func(response *http.Response, responseBody string)) error
AssertHandlerFunc test a request handler func with a test http request, see CreateIncomingRequest
func AssertResponseOfRequestCall ¶
func AssertResponseOfRequestCall(t *testing.T, request *http.Request, assertResponse func(response *http.Response, responseBody string)) error
AssertResponseOfRequestCall test a http request
func AssertResponseStatusOfRequestCall ¶
func AssertResponseStatusOfRequestCall(t *testing.T, request *http.Request, expectedResponseStatus int) error
AssertResponseStatusOfRequestCall test a http request
func CreateIncomingErrorReadingBodyRequest ¶
CreateIncomingErrorReadingBodyRequest create test http request which fails when reading the request body
func CreateIncomingRequest ¶
CreateIncomingRequest create test http request for a an input in a request handler func
func CreateOutgoingRequest ¶
func CreateOutgoingRequest(t *testing.T, method, path string, header Header, body string) *http.Request
CreateOutgoingRequest creates a http request
func RunAndCheckCoverage ¶
RunAndCheckCoverage use this in order to let the test fail when a coverage is not reached
Types ¶
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header type for http header
func (Header) WithJSONAccept ¶
WithJSONAccept adds JSON Accept to the header
func (Header) WithJSONContentType ¶
WithJSONContentType adds JSON Content-Type to the header
func (Header) WithKeyValue ¶
WithKeyValue adds key value to the header