(t *testing.T)
| 373 | } |
| 374 | |
| 375 | func TestDecompress_DefaultLimit(t *testing.T) { |
| 376 | e := echo.New() |
| 377 | smallBody := "test" |
| 378 | gz, _ := gzipString(smallBody) |
| 379 | |
| 380 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz)) |
| 381 | req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding) |
| 382 | rec := httptest.NewRecorder() |
| 383 | c := e.NewContext(req, rec) |
| 384 | |
| 385 | // Use zero value which should apply 100MB default |
| 386 | h, err := DecompressConfig{}.ToMiddleware() |
| 387 | assert.NoError(t, err) |
| 388 | |
| 389 | err = h(func(c *echo.Context) error { |
| 390 | b, _ := io.ReadAll(c.Request().Body) |
| 391 | return c.String(http.StatusOK, string(b)) |
| 392 | })(c) |
| 393 | |
| 394 | assert.NoError(t, err) |
| 395 | assert.Equal(t, smallBody, rec.Body.String()) |
| 396 | } |
| 397 | |
| 398 | func TestDecompress_SmallCustomLimit(t *testing.T) { |
| 399 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…