(t *testing.T)
| 217 | } |
| 218 | |
| 219 | func 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 | |
| 242 | func TestGzipWithMinLengthTooShort(t *testing.T) { |
| 243 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…