1
0
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:
Vishal Rana 2015-05-30 15:38:02 -07:00
parent b9eec15c01
commit 6d4864ac4f
2 changed files with 5 additions and 2 deletions

View File

@ -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)
}

View File

@ -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) {