Documentation ¶
Overview ¶
Package commontest holds methods which are helpful when writing tests within mediocre-api
Index ¶
- func APIStarterKit() util.Cmder
- func AssertReq(t *testing.T, mux http.Handler, method, endpoint, body, expectedBody string)
- func AssertReqErr(t *testing.T, mux http.Handler, method, endpoint, body string, ...)
- func AssertReqJSON(t *testing.T, mux http.Handler, method, endpoint, body string, dst interface{})
- func AssertReqRaw(t *testing.T, mux http.Handler, r *http.Request, expectedBody string)
- func AssertReqRawJSON(t *testing.T, mux http.Handler, r *http.Request, dst interface{})
- func RandEmail() string
- func RandStr() string
- func Req(t *testing.T, mux http.Handler, method, endpoint, body string) (int, string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIStarterKit ¶
APIStarterKit returns an initialized *API and a Cmder which can be used as generic entities for testing
func AssertReq ¶
AssertReq uses the stretchr/assert package to assert that the result of calling Req with the given arguments has a 200 response code and the given expectedBody
func AssertReqErr ¶
func AssertReqErr( t *testing.T, mux http.Handler, method, endpoint, body string, err common.ExpectedErr, )
AssertReqErr uses the stretchr/assert package to assert that the result of calling Req with the given arguments has a response code equal to the given ExpectedErr's and a body the same as well
func AssertReqJSON ¶
func AssertReqJSON( t *testing.T, mux http.Handler, method, endpoint, body string, dst interface{}, )
AssertReqJSON uses the stretchr/assert package to assert that the result of calling Req with the given arguments has a 200 response and a body which is unmarshaled into dst successfully.
func AssertReqRaw ¶
AssertReqRaw uses the stretchr/assert package to assert that the result of executing the given *http.Request returns a 200 response code and the given expectedBody
func AssertReqRawJSON ¶
AssertReqRawJSON uses the stretchr/assert package to assert that the result of executing the given *http.Request returns a 200 response and a body which is unmarshaled into dst successfully.
Types ¶
This section is empty.