Testing Echo Requests including middleware #2613
safaci2000
started this conversation in
General
Replies: 1 comment 1 reply
-
func TestTest(t *testing.T) {
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusNotImplemented, "OK")
})
req := httptest.NewRequest(http.MethodGet, "/?tags=1&tags=2", nil)
rec := httptest.NewRecorder()
e.ServeHTTP(rec, req)
assert.Equal(t, http.StatusNotImplemented, rec.Code)
assert.Equal(t, "OK", rec.Body.String())
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've moved some authorization pattern out of the body of my request call into a middleware layer, Is there a pattern which would allow me to validate the request call including middleware?
For example:
this is my test code currently, or a snippet of it. This all works great unless I use middlware and then it all goes out the window. Can I invoke the same middlware layer into the tests?
Beta Was this translation helpful? Give feedback.
All reactions