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

Function TestGzip_Empty

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

Source from the content-addressed store, hash-verified

145}
146
147func TestGzip_Empty(t *testing.T) {
148 e := echo.New()
149 req := httptest.NewRequest(http.MethodGet, "/", nil)
150 req.Header.Set(echo.HeaderAcceptEncoding, gzipScheme)
151 rec := httptest.NewRecorder()
152 c := e.NewContext(req, rec)
153 h := Gzip()(func(c *echo.Context) error {
154 return c.String(http.StatusOK, "")
155 })
156 if assert.NoError(t, h(c)) {
157 assert.Equal(t, gzipScheme, rec.Header().Get(echo.HeaderContentEncoding))
158 assert.Equal(t, "text/plain; charset=UTF-8", rec.Header().Get(echo.HeaderContentType))
159 r, err := gzip.NewReader(rec.Body)
160 if assert.NoError(t, err) {
161 var buf bytes.Buffer
162 buf.ReadFrom(r)
163 assert.Equal(t, "", buf.String())
164 }
165 }
166}
167
168func TestGzip_ErrorReturned(t *testing.T) {
169 e := echo.New()

Callers

nothing calls this directly

Calls 6

StringMethod · 0.95
GzipFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…