-
Notifications
You must be signed in to change notification settings - Fork 1
/
response_test.go
65 lines (60 loc) · 1.14 KB
/
response_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
53
54
55
56
57
58
59
60
61
62
63
64
65
package katapult
import (
"net/http"
"testing"
"github.com/krystal/go-katapult/internal/test"
"github.com/stretchr/testify/assert"
)
func TestPagination_JSONMarshaling(t *testing.T) {
tests := []struct {
name string
obj *Pagination
}{
{
name: "empty",
obj: &Pagination{},
},
{
name: "full",
obj: &Pagination{
CurrentPage: 5,
TotalPages: 10,
Total: 190,
PerPage: 20,
LargeSet: true,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
test.CustomJSONMarshaling(t, tt.obj, nil)
})
}
}
func TestNewResponse(t *testing.T) {
tests := []struct {
name string
r *http.Response
want *Response
}{
{
name: "given nil",
r: nil,
want: &Response{Response: &http.Response{}},
},
{
name: "given http.Response",
r: &http.Response{StatusCode: http.StatusEarlyHints},
want: &Response{
Response: &http.Response{StatusCode: http.StatusEarlyHints},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewResponse(tt.r)
assert.Equal(t, tt.want, got)
assert.IsType(t, int(0), got.StatusCode)
})
}
}