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

Function TestDecompress_DefaultLimit

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

Source from the content-addressed store, hash-verified

373}
374
375func 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
398func TestDecompress_SmallCustomLimit(t *testing.T) {
399 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…