-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_test.go
61 lines (44 loc) · 1.08 KB
/
client_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
package elation
import (
"testing"
"github.com/stretchr/testify/assert"
)
type resource struct {
ID int64
}
func TestResponse_HasPrevious(t *testing.T) {
assert := assert.New(t)
res := &Response[*resource]{}
assert.False(res.HasPrevious())
res.Previous = "foo"
assert.True(res.HasPrevious())
}
func TestResponse_HasNext(t *testing.T) {
assert := assert.New(t)
res := &Response[*resource]{}
assert.False(res.HasNext())
res.Next = "foo"
assert.True(res.HasNext())
}
func TestResponse_PaginationNext_PaginationPrevious(t *testing.T) {
assert := assert.New(t)
res := &Response[*resource]{}
assert.Equal(&Pagination{
Limit: defaultPaginationLimit,
Offset: 0,
}, res.PaginationNext())
assert.Equal(&Pagination{
Limit: defaultPaginationLimit,
Offset: 0,
}, res.PaginationPrevious())
res.Next = "https://domain.com/foo?limit=5&offset=10"
assert.Equal(&Pagination{
Limit: 5,
Offset: 10,
}, res.PaginationNext())
res.Previous = "https://domain.com/foo?limit=15&offset=20"
assert.Equal(&Pagination{
Limit: 15,
Offset: 20,
}, res.PaginationPrevious())
}