-
Notifications
You must be signed in to change notification settings - Fork 1
/
accounting_params_test.go
120 lines (103 loc) · 3.89 KB
/
accounting_params_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package modzy
import (
"strings"
"testing"
)
func TestListAccountingUsersInputWithPaging(t *testing.T) {
i := &ListAccountingUsersInput{}
i.WithPaging(4, 5)
if i.Paging.PerPage != 4 {
t.Errorf("expected perPage to be 4, got %d", i.Paging.PerPage)
}
if i.Paging.Page != 5 {
t.Errorf("expected page to be 5, got %d", i.Paging.Page)
}
}
func TestListAccountingUsersInputWithFilter(t *testing.T) {
i := &ListAccountingUsersInput{}
i.WithFilter(ListAccountingUsersFilterFieldAccessKey, "a")
if i.Paging.Filters[0].Field != "accessKey" {
t.Errorf("expected filter field to be accessKey, got %s", i.Paging.Filters[0].Field)
}
if i.Paging.Filters[0].Type != "AND" {
t.Errorf("expected filter type to be AND, got %s", i.Paging.Filters[0].Type)
}
if strings.Join(i.Paging.Filters[0].Values, ",") != "a" {
t.Errorf("expected filter values to be [a], got %+v", i.Paging.Filters[0].Values)
}
}
func TestListAccountingUsersInputWithFilterAnd(t *testing.T) {
i := &ListAccountingUsersInput{}
i.WithFilterAnd(ListAccountingUsersFilterFieldAccessKey, "a", "b")
if i.Paging.Filters[0].Field != "accessKey" {
t.Errorf("expected filter field to be accessKey, got %s", i.Paging.Filters[0].Field)
}
if i.Paging.Filters[0].Type != "AND" {
t.Errorf("expected filter type to be AND, got %s", i.Paging.Filters[0].Type)
}
if strings.Join(i.Paging.Filters[0].Values, ",") != "a,b" {
t.Errorf("expected filter values to be [a, b], got %+v", i.Paging.Filters[0].Values)
}
}
func TestListAccountingUsersInputWithFilterOr(t *testing.T) {
i := &ListAccountingUsersInput{}
i.WithFilterOr(ListAccountingUsersFilterFieldAccessKey, "c", "d")
if i.Paging.Filters[0].Field != "accessKey" {
t.Errorf("expected filter field to be accessKey, got %s", i.Paging.Filters[0].Field)
}
if i.Paging.Filters[0].Type != "OR" {
t.Errorf("expected filter type to be OR, got %s", i.Paging.Filters[0].Type)
}
if strings.Join(i.Paging.Filters[0].Values, ",") != "c,d" {
t.Errorf("expected filter values to be [c, d], got %+v", i.Paging.Filters[0].Values)
}
}
func TestListProjectsInputWithPaging(t *testing.T) {
i := &ListProjectsInput{}
i.WithPaging(4, 5)
if i.Paging.PerPage != 4 {
t.Errorf("expected perPage to be 4, got %d", i.Paging.PerPage)
}
if i.Paging.Page != 5 {
t.Errorf("expected page to be 5, got %d", i.Paging.Page)
}
}
func TestListProjectsInputWithFilter(t *testing.T) {
i := &ListProjectsInput{}
i.WithFilter(ListProjectsFilterFieldSearch, "a")
if i.Paging.Filters[0].Field != "search" {
t.Errorf("expected filter field to be search, got %s", i.Paging.Filters[0].Field)
}
if i.Paging.Filters[0].Type != "AND" {
t.Errorf("expected filter type to be AND, got %s", i.Paging.Filters[0].Type)
}
if strings.Join(i.Paging.Filters[0].Values, ",") != "a" {
t.Errorf("expected filter values to be [a], got %+v", i.Paging.Filters[0].Values)
}
}
func TestListProjectsInputWithFilterAnd(t *testing.T) {
i := &ListProjectsInput{}
i.WithFilterAnd(ListProjectsFilterFieldSearch, "a", "b")
if i.Paging.Filters[0].Field != "search" {
t.Errorf("expected filter field to be search, got %s", i.Paging.Filters[0].Field)
}
if i.Paging.Filters[0].Type != "AND" {
t.Errorf("expected filter type to be AND, got %s", i.Paging.Filters[0].Type)
}
if strings.Join(i.Paging.Filters[0].Values, ",") != "a,b" {
t.Errorf("expected filter values to be [a, b], got %+v", i.Paging.Filters[0].Values)
}
}
func TestListProjectsInputWithFilterOr(t *testing.T) {
i := &ListProjectsInput{}
i.WithFilterOr(ListProjectsFilterFieldStatus, "c", "d")
if i.Paging.Filters[0].Field != "status" {
t.Errorf("expected filter field to be status, got %s", i.Paging.Filters[0].Field)
}
if i.Paging.Filters[0].Type != "OR" {
t.Errorf("expected filter type to be OR, got %s", i.Paging.Filters[0].Type)
}
if strings.Join(i.Paging.Filters[0].Values, ",") != "c,d" {
t.Errorf("expected filter values to be [c, d], got %+v", i.Paging.Filters[0].Values)
}
}