-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathheaders_test.go
51 lines (46 loc) · 1.03 KB
/
headers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package api_tests
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/sharat87/httpbun/c"
)
func TestHeaders(t *testing.T) {
s := assert.New(t)
resp, body := ExecRequest(R{
Path: "headers",
Headers: map[string][]string{
"X-One": {"custom header value"},
"X-Two": {"another custom header"},
},
})
s.Equal(http.StatusOK, resp.StatusCode)
s.Equal(c.ApplicationJSON, resp.Header.Get(c.ContentType))
s.JSONEq(`{
"headers": {
"Accept-Encoding": "gzip",
"X-One": "custom header value",
"X-Two": "another custom header"
}
}`, body)
}
func TestHeadersRepeat(t *testing.T) {
s := assert.New(t)
resp, body := ExecRequest(R{
Path: "headers",
Headers: map[string][]string{
"X-One": {"custom header value", "another custom header"},
},
})
s.Equal(http.StatusOK, resp.StatusCode)
s.Equal(c.ApplicationJSON, resp.Header.Get(c.ContentType))
s.JSONEq(`{
"headers": {
"Accept-Encoding": "gzip",
"X-One": [
"custom header value",
"another custom header"
]
}
}`, body)
}