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

Function TestDecompress_SmallCustomLimit

middleware/decompress_test.go:398–418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

396}
397
398func TestDecompress_SmallCustomLimit(t *testing.T) {
399 e := echo.New()
400 body := strings.Repeat("D", 512) // 512 bytes
401 gz, _ := gzipString(body)
402
403 req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz))
404 req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding)
405 rec := httptest.NewRecorder()
406 c := e.NewContext(req, rec)
407
408 h, err := DecompressConfig{MaxDecompressedSize: 1024}.ToMiddleware() // 1KB limit
409 assert.NoError(t, err)
410
411 err = h(func(c *echo.Context) error {
412 b, _ := io.ReadAll(c.Request().Body)
413 return c.String(http.StatusOK, string(b))
414 })(c)
415
416 assert.NoError(t, err)
417 assert.Equal(t, body, rec.Body.String())
418}
419
420func TestDecompress_MultipleReads(t *testing.T) {
421 e := echo.New()

Callers

nothing calls this directly

Calls 6

RequestMethod · 0.95
StringMethod · 0.95
gzipStringFunction · 0.85
SetMethod · 0.80
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…