-
Notifications
You must be signed in to change notification settings - Fork 269
/
filter_test.go
44 lines (37 loc) · 1.22 KB
/
filter_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
package paypal
import (
"testing"
"time"
)
func TestFilter_AddTextField(t *testing.T) {
filter := &Filter{}
filter.AddTextField("sort_by").Is = "create_time"
filter.AddTextField("count").Is = "30"
filter.AddTextField("sort_order").Is = "desc"
expected := "?sort_by=create_time&count=30&sort_order=desc"
if filter.String() != expected {
t.Errorf("filter string was %s, wanted %s", filter.String(), expected)
}
}
func TestFilter_AddTimeField(t *testing.T) {
filter := &Filter{}
startTime := time.Time{}
endTime := startTime.Add(time.Hour * 24 * 30)
filter.AddTimeField("start_time").Is = startTime
filter.AddTimeField("stop_time").Is = endTime
expected := "?start_time=0001-01-01T00:00:00Z&stop_time=0001-01-31T00:00:00Z"
if filter.String() != expected {
t.Errorf("filter string was %s, wanted %s", filter.String(), expected)
}
}
func TestFilter_AddMixedFields(t *testing.T) {
filter := &Filter{}
startTime := time.Time{}
endTime := startTime.Add(time.Hour * 24 * 30)
filter.AddTimeField("stop_time").Is = endTime
filter.AddTextField("count").Is = "30"
expected := "?stop_time=0001-01-31T00:00:00Z&count=30"
if filter.String() != expected {
t.Errorf("filter string was %s, wanted %s", filter.String(), expected)
}
}