MCPcopy
hub / github.com/labstack/echo / TestBodyDump_skipper

Function TestBodyDump_skipper

middleware/body_dump_test.go:49–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestBodyDump_skipper(t *testing.T) {
50 e := echo.New()
51
52 isCalled := false
53 mw, err := BodyDumpConfig{
54 Skipper: func(c *echo.Context) bool {
55 return true
56 },
57 Handler: func(c *echo.Context, reqBody, resBody []byte, err error) {
58 isCalled = true
59 },
60 }.ToMiddleware()
61 assert.NoError(t, err)
62
63 req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader("{}"))
64 rec := httptest.NewRecorder()
65 c := e.NewContext(req, rec)
66 h := func(c *echo.Context) error {
67 return errors.New("some error")
68 }
69
70 err = mw(h)(c)
71 assert.EqualError(t, err, "some error")
72 assert.False(t, isCalled)
73}
74
75func TestBodyDump_fails(t *testing.T) {
76 e := echo.New()

Callers

nothing calls this directly

Calls 2

NewContextMethod · 0.80
ToMiddlewareMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…