Skip to content

Commit

Permalink
Test that ContentTypes returns copied slice
Browse files Browse the repository at this point in the history
  • Loading branch information
tmthrgd committed Dec 3, 2017
1 parent 1e9627c commit 0eb5dd9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,16 @@ func TestContentTypesMultiWrite(t *testing.T) {
assert.Equal(t, testBody+testBody, resp.Body.String())
}

func TestContentTypesCopies(t *testing.T) {
s := []string{"application/example"}

var c config
ContentTypes(s)(&c)

require.NotEmpty(t, c.contentTypes)
assert.False(t, &c.contentTypes[0] == &s[0], "ContentTypes returned same slice")
}

func TestGzipHandlerAlreadyCompressed(t *testing.T) {
handler := Gzip(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Encoding", "br")
Expand Down

0 comments on commit 0eb5dd9

Please sign in to comment.