Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call Verify GHTTPWithGomega receiver funcs #454

Merged
merged 1 commit into from Jul 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions ghttp/handlers.go
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