diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-01-18 07:23:48 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-01-18 07:23:48 +0200 |
commit | 4985a4c9567fdb2837adc14bcb442bd28ed89263 (patch) | |
tree | 5a5c2341653a49cba07d1d68fb01c58bb4e1e45d /fs_test.go | |
parent | Added ServeFile and ServeFileUncompressed to be on par with net/http (diff) | |
download | fasthttp-4985a4c9567fdb2837adc14bcb442bd28ed89263.tar.gz fasthttp-4985a4c9567fdb2837adc14bcb442bd28ed89263.tar.bz2 fasthttp-4985a4c9567fdb2837adc14bcb442bd28ed89263.zip |
Improved ServeFile* tests
Diffstat (limited to 'fs_test.go')
-rw-r--r-- | fs_test.go | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -28,8 +28,9 @@ func TestFSServeFileCompressed(t *testing.T) { t.Fatalf("unexpected error: %s", err) } - if string(resp.Header.Peek("Content-Encoding")) != "gzip" { - t.Fatalf("Unexpected 'Content-Encoding' %q. Expecting %q", resp.Header.Peek("Content-Encoding"), "gzip") + ce := resp.Header.Peek("Content-Encoding") + if string(ce) != "gzip" { + t.Fatalf("Unexpected 'Content-Encoding' %q. Expecting %q", ce, "gzip") } body, err := resp.BodyGunzip() @@ -49,6 +50,7 @@ func TestFSServeFileUncompressed(t *testing.T) { var ctx RequestCtx var req Request req.SetRequestURI("http://foobar.com/baz") + req.Header.Set("Accept-Encoding", "gzip") ctx.Init(&req, nil, nil) ServeFileUncompressed(&ctx, "fs.go") @@ -60,6 +62,11 @@ func TestFSServeFileUncompressed(t *testing.T) { t.Fatalf("unexpected error: %s", err) } + ce := resp.Header.Peek("Content-Encoding") + if len(ce) > 0 { + t.Fatalf("Unexpected 'Content-Encoding' %q", ce) + } + body := resp.Body() expectedBody, err := getFileContents("/fs.go") if err != nil { |