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

Function TestGzipWithMinLength

middleware/compress_test.go:219–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestGzipWithMinLength(t *testing.T) {
220 e := echo.New()
221 // Minimal response length
222 e.Use(GzipWithConfig(GzipConfig{MinLength: 10}))
223 e.GET("/", func(c *echo.Context) error {
224 c.Response().Write([]byte("foobarfoobar"))
225 return nil
226 })
227
228 req := httptest.NewRequest(http.MethodGet, "/", nil)
229 req.Header.Set(echo.HeaderAcceptEncoding, gzipScheme)
230 rec := httptest.NewRecorder()
231 e.ServeHTTP(rec, req)
232 assert.Equal(t, gzipScheme, rec.Header().Get(echo.HeaderContentEncoding))
233 r, err := gzip.NewReader(rec.Body)
234 if assert.NoError(t, err) {
235 buf := new(bytes.Buffer)
236 defer r.Close()
237 buf.ReadFrom(r)
238 assert.Equal(t, "foobarfoobar", buf.String())
239 }
240}
241
242func TestGzipWithMinLengthTooShort(t *testing.T) {
243 e := echo.New()

Callers

nothing calls this directly

Calls 11

GzipWithConfigFunction · 0.85
ResponseMethod · 0.80
SetMethod · 0.80
ServeHTTPMethod · 0.80
UseMethod · 0.45
GETMethod · 0.45
WriteMethod · 0.45
GetMethod · 0.45
HeaderMethod · 0.45
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…