1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-15 01:34:53 +02:00

v2 is compiling now

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-01-28 23:46:11 -08:00
parent dbd1e8e230
commit 688293b5ed
37 changed files with 832 additions and 1212 deletions

View File

@ -2,23 +2,23 @@ package middleware
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/labstack/echo"
"github.com/labstack/echo/test"
"github.com/stretchr/testify/assert"
)
func TestRecover(t *testing.T) {
e := echo.New()
e.SetDebug(true)
req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec, e), e)
req := test.NewRequest(echo.GET, "/", nil)
res := test.NewResponseRecorder()
c := echo.NewContext(req, res, e)
h := func(c echo.Context) error {
panic("test")
}
Recover()(h)(c)
assert.Equal(t, http.StatusInternalServerError, rec.Code)
assert.Contains(t, rec.Body.String(), "panic recover")
assert.Equal(t, http.StatusInternalServerError, res.Status())
assert.Contains(t, res.Body.String(), "panic recover")
}