Skip to content

Commit

Permalink
Call Verify GHTTPWithGomega receiver funcs (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
macaptain authored Jul 7, 2021
1 parent 9da0d13 commit 496e6fd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ghttp/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (g GHTTPWithGomega) VerifyHeader(header http.Header) http.HandlerFunc {
//(recall that a `http.Header` is a mapping from string (key) to []string (values))
//It is a convenience wrapper around `VerifyHeader` that allows you to avoid having to create an `http.Header` object.
func (g GHTTPWithGomega) VerifyHeaderKV(key string, values ...string) http.HandlerFunc {
return VerifyHeader(http.Header{key: values})
return g.VerifyHeader(http.Header{key: values})
}

//VerifyBody returns a handler that verifies that the body of the request matches the passed in byte array.
Expand All @@ -131,7 +131,7 @@ func (g GHTTPWithGomega) VerifyBody(expectedBody []byte) http.HandlerFunc {
//VerifyJSON also verifies that the request's content type is application/json
func (g GHTTPWithGomega) VerifyJSON(expectedJSON string) http.HandlerFunc {
return CombineHandlers(
VerifyMimeType("application/json"),
g.VerifyMimeType("application/json"),
func(w http.ResponseWriter, req *http.Request) {
body, err := ioutil.ReadAll(req.Body)
req.Body.Close()
Expand All @@ -148,8 +148,8 @@ func (g GHTTPWithGomega) VerifyJSONRepresenting(object interface{}) http.Handler
data, err := json.Marshal(object)
g.gomega.Expect(err).ShouldNot(HaveOccurred())
return CombineHandlers(
VerifyMimeType("application/json"),
VerifyJSON(string(data)),
g.VerifyMimeType("application/json"),
g.VerifyJSON(string(data)),
)
}

Expand All @@ -171,7 +171,7 @@ func (g GHTTPWithGomega) VerifyForm(values url.Values) http.HandlerFunc {
//
//It is a convenience wrapper around `VerifyForm` that lets you avoid having to create a `url.Values` object.
func (g GHTTPWithGomega) VerifyFormKV(key string, values ...string) http.HandlerFunc {
return VerifyForm(url.Values{key: values})
return g.VerifyForm(url.Values{key: values})
}

//VerifyProtoRepresenting returns a handler that verifies that the body of the request is a valid protobuf
Expand All @@ -180,7 +180,7 @@ func (g GHTTPWithGomega) VerifyFormKV(key string, values ...string) http.Handler
//VerifyProtoRepresenting also verifies that the request's content type is application/x-protobuf
func (g GHTTPWithGomega) VerifyProtoRepresenting(expected proto.Message) http.HandlerFunc {
return CombineHandlers(
VerifyContentType("application/x-protobuf"),
g.VerifyContentType("application/x-protobuf"),
func(w http.ResponseWriter, req *http.Request) {
body, err := ioutil.ReadAll(req.Body)
g.gomega.Expect(err).ShouldNot(HaveOccurred())
Expand Down

0 comments on commit 496e6fd

Please sign in to comment.