-
Notifications
You must be signed in to change notification settings - Fork 18
/
request_test.go
52 lines (46 loc) · 991 Bytes
/
request_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
52
package cute
import (
"net/http"
"net/url"
"testing"
"github.com/stretchr/testify/require"
)
func TestRequest(t *testing.T) {
var (
req = newRequestOptions()
headers = map[string][]string{
"key": []string{
"value",
},
}
query = map[string][]string{
"query_key": []string{
"query_value",
},
}
method = http.MethodGet
mBody = map[string]interface{}{
"key": map[string]interface{}{
"some": "value",
},
"key_twi": "more",
}
uri = "https://goo.com"
u, _ = url.Parse("https://ho.com")
body = []byte("body")
)
WithHeaders(headers)(req)
WithMarshalBody(mBody)(req)
WithURI(uri)(req)
WithMethod(method)(req)
WithURL(u)(req)
WithBody(body)(req)
WithQuery(query)(req)
require.Equal(t, req.headers, headers)
require.Equal(t, req.uri, uri)
require.Equal(t, req.bodyMarshal, mBody)
require.Equal(t, req.method, method)
require.Equal(t, req.query, query)
require.Equal(t, req.body, body)
require.Equal(t, req.url, u)
}