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

Function TestBodyDump_fails

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

Source from the content-addressed store, hash-verified

73}
74
75func TestBodyDump_fails(t *testing.T) {
76 e := echo.New()
77 hw := "Hello, World!"
78 req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(hw))
79 rec := httptest.NewRecorder()
80 c := e.NewContext(req, rec)
81 h := func(c *echo.Context) error {
82 return errors.New("some error")
83 }
84
85 mw, err := BodyDumpConfig{Handler: func(c *echo.Context, reqBody, resBody []byte, err error) {}}.ToMiddleware()
86 assert.NoError(t, err)
87
88 err = mw(h)(c)
89 assert.EqualError(t, err, "some error")
90 assert.Equal(t, http.StatusOK, rec.Code)
91
92}
93
94func TestBodyDumpWithConfig_panic(t *testing.T) {
95 assert.Panics(t, func() {

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…