(t *testing.T)
| 147 | } |
| 148 | |
| 149 | func TestBodyLimitWithConfig(t *testing.T) { |
| 150 | e := echo.New() |
| 151 | hw := []byte("Hello, World!") |
| 152 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw)) |
| 153 | rec := httptest.NewRecorder() |
| 154 | c := e.NewContext(req, rec) |
| 155 | h := func(c *echo.Context) error { |
| 156 | body, err := io.ReadAll(c.Request().Body) |
| 157 | if err != nil { |
| 158 | return err |
| 159 | } |
| 160 | return c.String(http.StatusOK, string(body)) |
| 161 | } |
| 162 | |
| 163 | mw := BodyLimitWithConfig(BodyLimitConfig{LimitBytes: 2 * MB}) |
| 164 | |
| 165 | err := mw(h)(c) |
| 166 | assert.NoError(t, err) |
| 167 | assert.Equal(t, http.StatusOK, rec.Code) |
| 168 | assert.Equal(t, hw, rec.Body.Bytes()) |
| 169 | } |
| 170 | |
| 171 | func TestBodyLimit(t *testing.T) { |
| 172 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…