mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Fixed router tests
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
b9eec15c01
commit
6d4864ac4f
@ -307,8 +307,9 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
h, _ := r.Find(req.Method, req.URL.Path, c)
|
||||
c.reset(req, w, r.echo)
|
||||
if h == nil {
|
||||
h = r.echo.notFoundHandler
|
||||
c.Error(NewHTTPError(http.StatusNotFound))
|
||||
} else {
|
||||
h(c)
|
||||
}
|
||||
h(c)
|
||||
r.echo.pool.Put(c)
|
||||
}
|
||||
|
@ -531,11 +531,13 @@ func TestRouterServeHTTP(t *testing.T) {
|
||||
req, _ := http.NewRequest(GET, "/users", nil)
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
assert.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
// Not found
|
||||
req, _ = http.NewRequest(GET, "/files", nil)
|
||||
w = httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
assert.Equal(t, http.StatusNotFound, w.Code)
|
||||
}
|
||||
|
||||
func (n *node) printTree(pfx string, tail bool) {
|
||||
|
Loading…
Reference in New Issue
Block a user