MCPcopy Index your code
hub / github.com/labstack/echo / TestDecompress_WithinLimit

Function TestDecompress_WithinLimit

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

Source from the content-addressed store, hash-verified

251}
252
253func TestDecompress_WithinLimit(t *testing.T) {
254 e := echo.New()
255 body := strings.Repeat("test data ", 100) // Small payload ~1KB
256 gz, _ := gzipString(body)
257
258 req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz))
259 req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding)
260 rec := httptest.NewRecorder()
261 c := e.NewContext(req, rec)
262
263 h, err := DecompressConfig{MaxDecompressedSize: 100 * MB}.ToMiddleware()
264 assert.NoError(t, err)
265
266 err = h(func(c *echo.Context) error {
267 b, _ := io.ReadAll(c.Request().Body)
268 return c.String(http.StatusOK, string(b))
269 })(c)
270
271 assert.NoError(t, err)
272 assert.Equal(t, body, rec.Body.String())
273}
274
275func TestDecompress_ExceedsLimit(t *testing.T) {
276 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…