@@ -86,48 +86,43 @@ class MullvadAPIWrapper {
86
86
87
87
func createAccount( ) -> String {
88
88
var accountNumber = String ( )
89
- var requestError : Error ?
90
89
let requestCompletedExpectation = XCTestExpectation ( description: " Create account request completed " )
91
90
92
91
throttle {
93
92
do {
94
93
accountNumber = try self . mullvadAPI. createAccount ( )
95
94
} catch {
96
- requestError = MullvadAPIError . requestError
95
+ XCTFail ( " Failed to create account with error: \( error . localizedDescription ) " )
97
96
}
98
97
99
98
requestCompletedExpectation. fulfill ( )
100
99
}
101
100
102
101
let waitResult = XCTWaiter ( ) . wait ( for: [ requestCompletedExpectation] , timeout: throttleWaitTimeout)
103
102
XCTAssertEqual ( waitResult, . completed, " Create account request completed " )
104
- XCTAssertNil ( requestError, " Create account error is nil " )
105
103
106
104
return accountNumber
107
105
}
108
106
109
107
func deleteAccount( _ accountNumber: String ) {
110
- var requestError : Error ?
111
108
let requestCompletedExpectation = XCTestExpectation ( description: " Delete account request completed " )
112
109
113
110
throttle {
114
111
do {
115
112
try self . mullvadAPI. delete ( account: accountNumber)
116
113
} catch {
117
- requestError = MullvadAPIError . requestError
114
+ XCTFail ( " Failed to delete account with error: \( error . localizedDescription ) " )
118
115
}
119
116
120
117
requestCompletedExpectation. fulfill ( )
121
118
}
122
119
123
120
let waitResult = XCTWaiter ( ) . wait ( for: [ requestCompletedExpectation] , timeout: throttleWaitTimeout)
124
121
XCTAssertEqual ( waitResult, . completed, " Delete account request completed " )
125
- XCTAssertNil ( requestError, " Delete account error is nil " )
126
122
}
127
123
128
124
/// Add another device to specified account. A dummy WireGuard key will be generated.
129
125
func addDevice( _ account: String ) {
130
- var addDeviceError : Error ?
131
126
let requestCompletedExpectation = XCTestExpectation ( description: " Add device request completed " )
132
127
133
128
throttle {
@@ -136,15 +131,14 @@ class MullvadAPIWrapper {
136
131
do {
137
132
try self . mullvadAPI. addDevice ( forAccount: account, publicKey: devicePublicKey)
138
133
} catch {
139
- addDeviceError = MullvadAPIError . requestError
134
+ XCTFail ( " Failed to add device with error: \( error . localizedDescription ) " )
140
135
}
141
136
142
137
requestCompletedExpectation. fulfill ( )
143
138
}
144
139
145
140
let waitResult = XCTWaiter ( ) . wait ( for: [ requestCompletedExpectation] , timeout: throttleWaitTimeout)
146
141
XCTAssertEqual ( waitResult, . completed, " Add device request completed " )
147
- XCTAssertNil ( addDeviceError, " Add device error is nil " )
148
142
}
149
143
150
144
/// Add multiple devices to specified account. Dummy WireGuard keys will be generated.
@@ -157,45 +151,41 @@ class MullvadAPIWrapper {
157
151
158
152
func getAccountExpiry( _ account: String ) throws -> Date {
159
153
var accountExpiryDate : Date = . distantPast
160
- var requestError : Error ?
161
154
let requestCompletedExpectation = XCTestExpectation ( description: " Get account expiry request completed " )
162
155
163
156
throttle {
164
157
do {
165
158
let accountExpiryTimestamp = Double ( try self . mullvadAPI. getExpiry ( forAccount: account) )
166
159
accountExpiryDate = Date ( timeIntervalSince1970: accountExpiryTimestamp)
167
160
} catch {
168
- requestError = MullvadAPIError . requestError
161
+ XCTFail ( " Failed to get account expiry with error: \( error . localizedDescription ) " )
169
162
}
170
163
171
164
requestCompletedExpectation. fulfill ( )
172
165
}
173
166
174
167
let waitResult = XCTWaiter ( ) . wait ( for: [ requestCompletedExpectation] , timeout: throttleWaitTimeout)
175
168
XCTAssertEqual ( waitResult, . completed, " Get account expiry request completed " )
176
- XCTAssertNil ( requestError, " Get account expiry error is nil " )
177
169
178
170
return accountExpiryDate
179
171
}
180
172
181
173
func getDevices( _ account: String ) throws -> [ Device ] {
182
174
var devices : [ Device ] = [ ]
183
- var requestError : Error ?
184
175
let requestCompletedExpectation = XCTestExpectation ( description: " Get devices request completed " )
185
176
186
177
throttle {
187
178
do {
188
179
devices = try self . mullvadAPI. listDevices ( forAccount: account)
189
180
} catch {
190
- requestError = MullvadAPIError . requestError
181
+ XCTFail ( " Failed to get devices with error: \( error . localizedDescription ) " )
191
182
}
192
183
193
184
requestCompletedExpectation. fulfill ( )
194
185
}
195
186
196
187
let waitResult = XCTWaiter . wait ( for: [ requestCompletedExpectation] , timeout: throttleWaitTimeout)
197
188
XCTAssertEqual ( waitResult, . completed, " Get devices request completed " )
198
- XCTAssertNil ( requestError, " Get devices error is nil " )
199
189
200
190
return devices
201
191
}
0 commit comments