(t *testing.T)
| 169 | } |
| 170 | |
| 171 | func TestBodyLimit(t *testing.T) { |
| 172 | e := echo.New() |
| 173 | hw := []byte("Hello, World!") |
| 174 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw)) |
| 175 | rec := httptest.NewRecorder() |
| 176 | c := e.NewContext(req, rec) |
| 177 | h := func(c *echo.Context) error { |
| 178 | body, err := io.ReadAll(c.Request().Body) |
| 179 | if err != nil { |
| 180 | return err |
| 181 | } |
| 182 | return c.String(http.StatusOK, string(body)) |
| 183 | } |
| 184 | |
| 185 | mw := BodyLimit(2 * MB) |
| 186 | |
| 187 | err := mw(h)(c) |
| 188 | assert.NoError(t, err) |
| 189 | assert.Equal(t, http.StatusOK, rec.Code) |
| 190 | assert.Equal(t, hw, rec.Body.Bytes()) |
| 191 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…