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

Function TestDecompressWithConfig_DefaultConfig

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

Source from the content-addressed store, hash-verified

81}
82
83func TestDecompressWithConfig_DefaultConfig(t *testing.T) {
84 e := echo.New()
85
86 h := Decompress()(func(c *echo.Context) error {
87 c.Response().Write([]byte("test")) // For Content-Type sniffing
88 return nil
89 })
90
91 // Decompress
92 body := `{"name": "echo"}`
93 gz, _ := gzipString(body)
94 req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(string(gz)))
95 req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding)
96 rec := httptest.NewRecorder()
97 c := e.NewContext(req, rec)
98
99 err := h(c)
100 assert.NoError(t, err)
101
102 assert.Equal(t, GZIPEncoding, req.Header.Get(echo.HeaderContentEncoding))
103 b, err := io.ReadAll(req.Body)
104 assert.NoError(t, err)
105 assert.Equal(t, body, string(b))
106}
107
108func TestCompressRequestWithoutDecompressMiddleware(t *testing.T) {
109 e := echo.New()

Callers

nothing calls this directly

Calls 7

ResponseMethod · 0.95
DecompressFunction · 0.85
gzipStringFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
WriteMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…