-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpersonalbest_test.go
161 lines (130 loc) · 3.97 KB
/
personalbest_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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Copyright (c) 2015, Sgt. Kabukiman | MIT licensed
package srapi
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestPersonalBests(t *testing.T) {
countRequests = true
pac, _ := UserByID("wzx7q875")
Convey("Test fetching related resources", t, func() {
Convey("Game", func() {
Convey("Without embedding", func() {
pbs, err := pac.PersonalBests(nil, NoEmbeds)
So(err, ShouldBeNil)
game, err := pbs.First().Game(NoEmbeds)
So(err, ShouldBeNil)
So(game.ID, ShouldEqual, "om1m3625")
})
Convey("With embedding", func() {
pbs, err := pac.PersonalBests(nil, "game")
So(err, ShouldBeNil)
before := requestCount
game, err := pbs.First().Game(NoEmbeds)
So(err, ShouldBeNil)
So(game.ID, ShouldEqual, "om1m3625")
So(requestCount, ShouldEqual, before)
})
})
Convey("Category", func() {
Convey("Without embedding", func() {
pbs, err := pac.PersonalBests(nil, NoEmbeds)
So(err, ShouldBeNil)
category, err := pbs.First().Category(NoEmbeds)
So(err, ShouldBeNil)
So(category.ID, ShouldEqual, "w20p0zkn")
})
Convey("With embedding", func() {
pbs, err := pac.PersonalBests(nil, "category")
So(err, ShouldBeNil)
before := requestCount
category, err := pbs.First().Category(NoEmbeds)
So(err, ShouldBeNil)
So(category.ID, ShouldEqual, "w20p0zkn")
So(requestCount, ShouldEqual, before)
})
})
Convey("Level", func() {
Convey("Without embedding", func() {
pbs, err := pac.PersonalBests(nil, NoEmbeds)
So(err, ShouldBeNil)
level, err := pbs.Get(1).Level(NoEmbeds)
So(err, ShouldBeNil)
So(level.ID, ShouldEqual, "krdn5dm2")
})
Convey("With embedding", func() {
pbs, err := pac.PersonalBests(nil, "level")
So(err, ShouldBeNil)
before := requestCount
level, err := pbs.Get(1).Level(NoEmbeds)
So(err, ShouldBeNil)
So(level.ID, ShouldEqual, "krdn5dm2")
So(requestCount, ShouldEqual, before)
})
})
Convey("Platform", func() {
Convey("Without embedding", func() {
pbs, err := pac.PersonalBests(nil, NoEmbeds)
So(err, ShouldBeNil)
platform, err := pbs.First().Platform()
So(err, ShouldBeNil)
So(platform.ID, ShouldEqual, "rdjq4vwe")
})
Convey("With embedding", func() {
pbs, err := pac.PersonalBests(nil, "platform")
So(err, ShouldBeNil)
before := requestCount
platform, err := pbs.First().Platform()
So(err, ShouldBeNil)
So(platform.ID, ShouldEqual, "rdjq4vwe")
So(requestCount, ShouldEqual, before)
})
})
Convey("Region", func() {
Convey("Without embedding", func() {
pbs, err := pac.PersonalBests(nil, NoEmbeds)
So(err, ShouldBeNil)
region, err := pbs.First().Region()
So(err, ShouldBeNil)
So(region.ID, ShouldEqual, "pr184lqn")
})
Convey("With embedding", func() {
pbs, err := pac.PersonalBests(nil, "region")
So(err, ShouldBeNil)
before := requestCount
region, err := pbs.First().Region()
So(err, ShouldBeNil)
So(region.ID, ShouldEqual, "pr184lqn")
So(requestCount, ShouldEqual, before)
})
})
Convey("Players", func() {
Convey("Without embedding", func() {
pbs, err := pac.PersonalBests(nil, NoEmbeds)
So(err, ShouldBeNil)
players, err := pbs.First().Players()
So(err, ShouldBeNil)
So(players.Size(), ShouldEqual, 1)
So(players.First().User.ID, ShouldEqual, "wzx7q875")
})
Convey("With embedding", func() {
pbs, err := pac.PersonalBests(nil, "players")
So(err, ShouldBeNil)
before := requestCount
players, err := pbs.First().Players()
So(err, ShouldBeNil)
So(players.Size(), ShouldEqual, 1)
So(players.First().User.ID, ShouldEqual, "wzx7q875")
So(requestCount, ShouldEqual, before)
})
})
Convey("Examiner", func() {
pbs, err := pac.PersonalBests(nil, NoEmbeds)
So(err, ShouldBeNil)
examiner, err := pbs.Get(3).Examiner()
So(err, ShouldBeNil)
So(examiner, ShouldNotBeNil)
So(examiner.ID, ShouldEqual, "y8d4yl86")
})
})
}