Skip to content

Commit 73cbacf

Browse files
committed
add unit test for gzip middleware
case where gzip is disabled.
1 parent 18c88b2 commit 73cbacf

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

rest/gzip_test.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66
)
77

8-
func TestGzip(t *testing.T) {
8+
func TestGzipEnabled(t *testing.T) {
99

1010
handler := ResourceHandler{
1111
DisableJsonIndent: true,
@@ -36,3 +36,23 @@ func TestGzip(t *testing.T) {
3636
recorded.ContentEncodingIsGzip()
3737
recorded.HeaderIs("Vary", "Accept-Encoding")
3838
}
39+
40+
func TestGzipDisabled(t *testing.T) {
41+
42+
handler := ResourceHandler{
43+
DisableJsonIndent: true,
44+
}
45+
handler.SetRoutes(
46+
&Route{"GET", "/ok",
47+
func(w ResponseWriter, r *Request) {
48+
w.WriteJson(map[string]string{"Id": "123"})
49+
},
50+
},
51+
)
52+
53+
recorded := test.RunRequest(t, &handler, test.MakeSimpleRequest("GET", "http://1.2.3.4/ok", nil))
54+
recorded.CodeIs(200)
55+
recorded.ContentTypeIsJson()
56+
recorded.HeaderIs("Content-Encoding", "")
57+
recorded.HeaderIs("Vary", "")
58+
}

0 commit comments

Comments
 (0)