MCPcopy Index your code
hub / github.com/labstack/echo / TestRecover_skipper

Function TestRecover_skipper

middleware/recover_test.go:42–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestRecover_skipper(t *testing.T) {
43 e := echo.New()
44
45 req := httptest.NewRequest(http.MethodGet, "/", nil)
46 rec := httptest.NewRecorder()
47 c := e.NewContext(req, rec)
48
49 config := RecoverConfig{
50 Skipper: func(c *echo.Context) bool {
51 return true
52 },
53 }
54 h := RecoverWithConfig(config)(func(c *echo.Context) error {
55 panic("testPANIC")
56 })
57
58 var err error
59 assert.Panics(t, func() {
60 err = h(c)
61 })
62
63 assert.NoError(t, err)
64 assert.Equal(t, http.StatusOK, rec.Code) // status is still untouched. err is returned from middleware chain
65}
66
67func TestRecoverErrAbortHandler(t *testing.T) {
68 e := echo.New()

Callers

nothing calls this directly

Calls 2

RecoverWithConfigFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…