@@ -4,18 +4,6 @@ import (
4
4
"encoding/base64"
5
5
"encoding/json"
6
6
"testing"
7
- "time"
8
-
9
- "github.com/go-resty/resty/v2"
10
- )
11
-
12
- var (
13
- publicClient = resty .New ().
14
- SetBaseURL (PublicURL + "/mobile/v1" ).
15
- SetTimeout (300 * time .Millisecond )
16
- privateClient = resty .New ().
17
- SetBaseURL (PrivateURL + "/mobile/v1" ).
18
- SetTimeout (300 * time .Millisecond )
19
7
)
20
8
21
9
type mobileRegisterResponse struct {
@@ -24,27 +12,6 @@ type mobileRegisterResponse struct {
24
12
Password string `json:"password"`
25
13
}
26
14
27
- func mobileDeviceRegister (t * testing.T , client * resty.Client ) mobileRegisterResponse {
28
- res , err := client .R ().
29
- SetHeader ("Content-Type" , "application/json" ).
30
- SetBody (`{"name": "Public Device Name", "pushToken": "token"}` ).
31
- Post ("device" )
32
- if err != nil {
33
- t .Fatal (err )
34
- }
35
-
36
- if ! res .IsSuccess () {
37
- t .Fatal (res .StatusCode (), res .String ())
38
- }
39
-
40
- var resp mobileRegisterResponse
41
- if err := json .Unmarshal (res .Body (), & resp ); err != nil {
42
- t .Fatal (err )
43
- }
44
-
45
- return resp
46
- }
47
-
48
15
func TestPublicDeviceRegister (t * testing.T ) {
49
16
cases := []struct {
50
17
name string
@@ -74,7 +41,7 @@ func TestPublicDeviceRegister(t *testing.T) {
74
41
75
42
for _ , c := range cases {
76
43
t .Run (c .name , func (t * testing.T ) {
77
- res , err := publicClient .R ().
44
+ res , err := publicMobileClient .R ().
78
45
SetHeader ("Content-Type" , "application/json" ).
79
46
SetBody (`{"name": "Public Device Name", "pushToken": "token"}` ).
80
47
SetHeaders (c .headers ).
@@ -117,7 +84,7 @@ func TestPrivateDeviceRegister(t *testing.T) {
117
84
},
118
85
}
119
86
120
- client := privateClient
87
+ client := privateMobileClient
121
88
122
89
for _ , c := range cases {
123
90
t .Run (c .name , func (t * testing.T ) {
@@ -138,7 +105,7 @@ func TestPrivateDeviceRegister(t *testing.T) {
138
105
}
139
106
140
107
func TestPublicDevicePasswordChange (t * testing.T ) {
141
- device := mobileDeviceRegister (t , publicClient )
108
+ device := mobileDeviceRegister (t , publicMobileClient )
142
109
143
110
cases := []struct {
144
111
name string
@@ -190,7 +157,7 @@ func TestPublicDevicePasswordChange(t *testing.T) {
190
157
191
158
for _ , c := range cases {
192
159
t .Run (c .name , func (t * testing.T ) {
193
- res , err := publicClient .R ().
160
+ res , err := publicMobileClient .R ().
194
161
SetHeader ("Content-Type" , "application/json" ).
195
162
SetBody (c .body ).
196
163
SetHeaders (c .headers ).
@@ -210,7 +177,7 @@ func TestPublicDeviceRegisterWithCredentials(t *testing.T) {
210
177
// won't work with registration rate limits
211
178
t .SkipNow ()
212
179
213
- firstDevice := mobileDeviceRegister (t , publicClient )
180
+ firstDevice := mobileDeviceRegister (t , publicMobileClient )
214
181
215
182
cases := []struct {
216
183
name string
@@ -239,7 +206,7 @@ func TestPublicDeviceRegisterWithCredentials(t *testing.T) {
239
206
240
207
for _ , c := range cases {
241
208
t .Run (c .name , func (t * testing.T ) {
242
- res , err := publicClient .R ().
209
+ res , err := publicMobileClient .R ().
243
210
SetHeader ("Content-Type" , "application/json" ).
244
211
SetBody (`{"name": "Public Device Name", "pushToken": "token"}` ).
245
212
SetHeaders (c .headers ).
0 commit comments