mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Using _fixture for testing
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
998c5de65f
commit
7140e8395a
@ -67,7 +67,7 @@ func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc {
|
||||
res := c.Response()
|
||||
res.Header().Add(echo.HeaderVary, echo.HeaderAcceptEncoding)
|
||||
if strings.Contains(c.Request().Header.Get(echo.HeaderAcceptEncoding), gzipScheme) {
|
||||
res.Header().Add(echo.HeaderContentEncoding, gzipScheme) // issue #806
|
||||
res.Header().Add(echo.HeaderContentEncoding, gzipScheme) // Issue #806
|
||||
rw := res.Writer
|
||||
w, err := gzip.NewWriterLevel(rw, config.Level)
|
||||
if err != nil {
|
||||
|
@ -77,8 +77,8 @@ func TestGzipErrorReturned(t *testing.T) {
|
||||
func TestGzipWithStatic(t *testing.T) {
|
||||
e := echo.New()
|
||||
e.Use(Gzip())
|
||||
e.Static("/test", "testdata/compress")
|
||||
req, _ := http.NewRequest(echo.GET, "/test/data", nil)
|
||||
e.Static("/test", "../_fixture/images")
|
||||
req, _ := http.NewRequest(echo.GET, "/test/walle.png", nil)
|
||||
req.Header.Set(echo.HeaderAcceptEncoding, gzipScheme)
|
||||
rec := httptest.NewRecorder()
|
||||
e.ServeHTTP(rec, req)
|
||||
@ -91,7 +91,7 @@ func TestGzipWithStatic(t *testing.T) {
|
||||
r, err := gzip.NewReader(rec.Body)
|
||||
assert.NoError(t, err)
|
||||
defer r.Close()
|
||||
want, err := ioutil.ReadFile("testdata/compress/data")
|
||||
want, err := ioutil.ReadFile("../_fixture/images/walle.png")
|
||||
if assert.NoError(t, err) {
|
||||
var buf bytes.Buffer
|
||||
buf.ReadFrom(r)
|
||||
|
1
middleware/testdata/compress/data
vendored
1
middleware/testdata/compress/data
vendored
@ -1 +0,0 @@
|
||||
test data
|
Loading…
Reference in New Issue
Block a user