Documentation
¶
Index ¶
Constants ¶
View Source
const ( // got a request that isn't matched by any matcher StatusUnexpectedRequest = 600 // couldn't clone the request body StatusErrorCloningRequestBody = 601 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpectedRequest ¶
type ExpectedRequest struct { Matcher RequestMatcher Handler http.Handler }
ExpectedRequest is a request and response for your test
type RequestHandler ¶
type RequestHandler struct {
// contains filtered or unexported fields
}
RequestHandler is a handler that will serve responses for expected requests
func (*RequestHandler) Count ¶
func (r *RequestHandler) Count() int
Count returns the number of requests the handler has served
func (*RequestHandler) Expect ¶
func (r *RequestHandler) Expect(expectedRequest *ExpectedRequest)
Expect adds an expected request to the handler
func (*RequestHandler) ServeHTTP ¶
func (r *RequestHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type RequestMatcher ¶
RequestMatcher matches requests with responses
func MatchAll ¶
func MatchAll(matcher ...RequestMatcher) RequestMatcher
MatchAll matches when all matchers match the request
func MatchBody ¶
func MatchBody(wantBody string) RequestMatcher
MatchBody matches when the request's body is equal to wantBody
func MatchRequestPath ¶
func MatchRequestPath(wantPath string) RequestMatcher
MatchRequestPath matches when the request's URL path equals wantPath
func MatchRequestQuery ¶
func MatchRequestQuery(wantQuery string) RequestMatcher
MatchRequestQuery matches when the request's URL query matches wantQuery
Click to show internal directories.
Click to hide internal directories.