mirror of
https://github.com/labstack/echo.git
synced 2025-04-25 12:24:55 +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)
|
h, _ := r.Find(req.Method, req.URL.Path, c)
|
||||||
c.reset(req, w, r.echo)
|
c.reset(req, w, r.echo)
|
||||||
if h == nil {
|
if h == nil {
|
||||||
h = r.echo.notFoundHandler
|
c.Error(NewHTTPError(http.StatusNotFound))
|
||||||
|
} else {
|
||||||
|
h(c)
|
||||||
}
|
}
|
||||||
h(c)
|
|
||||||
r.echo.pool.Put(c)
|
r.echo.pool.Put(c)
|
||||||
}
|
}
|
||||||
|
@ -531,11 +531,13 @@ func TestRouterServeHTTP(t *testing.T) {
|
|||||||
req, _ := http.NewRequest(GET, "/users", nil)
|
req, _ := http.NewRequest(GET, "/users", nil)
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
r.ServeHTTP(w, req)
|
r.ServeHTTP(w, req)
|
||||||
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
|
|
||||||
// Not found
|
// Not found
|
||||||
req, _ = http.NewRequest(GET, "/files", nil)
|
req, _ = http.NewRequest(GET, "/files", nil)
|
||||||
w = httptest.NewRecorder()
|
w = httptest.NewRecorder()
|
||||||
r.ServeHTTP(w, req)
|
r.ServeHTTP(w, req)
|
||||||
|
assert.Equal(t, http.StatusNotFound, w.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) printTree(pfx string, tail bool) {
|
func (n *node) printTree(pfx string, tail bool) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user