-
Notifications
You must be signed in to change notification settings - Fork 2
/
gw2api_test.go
71 lines (62 loc) · 1.19 KB
/
gw2api_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
package gw2api
import "testing"
func TestNew(t *testing.T) {
api := New()
endpoint := "https://guilwars2.com"
api = api.WithEndpointAPI(endpoint)
if api.endpointAPI != endpoint {
t.Error("WithNewEndpointAPI failed")
}
token := "test"
api = api.WithAccessToken(token)
if api.accessToken != token {
t.Error("WithNewAccessToken failed")
}
lang := "de"
api = api.WithLanguage(lang)
if api.language != lang {
t.Error("WithLanguage failed")
}
}
func TestGenArgs(t *testing.T) {
cases := []struct {
given []int
expect string
}{
{
given: []int{},
expect: "?ids=all",
},
{
given: []int{1, 2},
expect: "?ids=1,2",
},
}
for _, c := range cases {
result := genArgs(c.given...)
if result != c.expect {
t.Error("genArgs failed: EXPECT: ", c.expect, " GOT: ", result)
}
}
}
func TestGenArgsString(t *testing.T) {
cases := []struct {
given []string
expect string
}{
{
given: []string{},
expect: "?ids=all",
},
{
given: []string{"A", "B"},
expect: "?ids=A,B",
},
}
for _, c := range cases {
result := genArgsString(c.given...)
if result != c.expect {
t.Error("genArgsString failed: EXPECT: ", c.expect, " GOT: ", result)
}
}
}