aboutsummaryrefslogtreecommitdiff
path: root/fs_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-01-18 07:23:48 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-01-18 07:23:48 +0200
commit4985a4c9567fdb2837adc14bcb442bd28ed89263 (patch)
tree5a5c2341653a49cba07d1d68fb01c58bb4e1e45d /fs_test.go
parentAdded ServeFile and ServeFileUncompressed to be on par with net/http (diff)
downloadfasthttp-4985a4c9567fdb2837adc14bcb442bd28ed89263.tar.gz
fasthttp-4985a4c9567fdb2837adc14bcb442bd28ed89263.tar.bz2
fasthttp-4985a4c9567fdb2837adc14bcb442bd28ed89263.zip
Improved ServeFile* tests
Diffstat (limited to 'fs_test.go')
-rw-r--r--fs_test.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs_test.go b/fs_test.go
index f2020e7..5d79487 100644
--- a/fs_test.go
+++ b/fs_test.go
@@ -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 {