|
7 | 7 | let(:fake_binary_contents) { "Hello World" } |
8 | 8 | let(:fake_binary) { double("Binary") } |
9 | 9 | let(:headers) { { 'Authorization' => 'Bearer auth_token' } } |
| 10 | + let(:upload_timeout) { 300 } |
10 | 11 |
|
11 | 12 | let(:api_client) { Fastlane::Client::FirebaseAppDistributionApiClient.new("auth_token") } |
12 | 13 | let(:stubs) { Faraday::Adapter::Test::Stubs.new } |
|
105 | 106 | } |
106 | 107 | ] |
107 | 108 | end |
108 | | - api_client.upload_binary(app_name, fake_binary_path, "android") |
| 109 | + api_client.upload_binary(app_name, fake_binary_path, "android", upload_timeout) |
109 | 110 | end |
110 | 111 |
|
111 | 112 | it 'crashes when given an invalid binary_path' do |
112 | 113 | expect(File).to receive(:open) |
113 | 114 | .with("invalid_binary.apk", "rb") |
114 | 115 | .and_raise(Errno::ENOENT.new("file not found")) |
115 | | - expect { api_client.upload_binary(app_name, "invalid_binary.apk", "android") } |
| 116 | + expect { api_client.upload_binary(app_name, "invalid_binary.apk", "android", upload_timeout) } |
116 | 117 | .to raise_error("#{ErrorMessage.binary_not_found('APK')}: invalid_binary.apk") |
117 | 118 | end |
118 | 119 | end |
|
185 | 186 |
|
186 | 187 | it 'uploads the app binary then returns the release name' do |
187 | 188 | expect(api_client).to receive(:upload_binary) |
188 | | - .with(app_name, fake_binary_path, "android") |
| 189 | + .with(app_name, fake_binary_path, "android", upload_timeout) |
189 | 190 | .and_return(operation_name) |
190 | 191 | .at_most(:once) |
191 | 192 | expect(api_client).to receive(:get_upload_status) |
|
197 | 198 | .and_return(upload_status_response_success) |
198 | 199 | .at_most(:once) |
199 | 200 |
|
200 | | - result = api_client.upload(app_name, fake_binary_path, "android") |
| 201 | + result = api_client.upload(app_name, fake_binary_path, "android", upload_timeout) |
201 | 202 | expect(result).to eq(release_name) |
202 | 203 | end |
203 | 204 |
|
204 | 205 | it 'uploads the app binary for an existing unmodified binary' do |
205 | 206 | expect(api_client).to receive(:upload_binary) |
206 | | - .with(app_name, fake_binary_path, "android") |
| 207 | + .with(app_name, fake_binary_path, "android", upload_timeout) |
207 | 208 | .and_return(operation_name) |
208 | 209 | .at_most(:once) |
209 | 210 | expect(api_client).to receive(:get_upload_status) |
|
215 | 216 | .and_return(upload_status_response_release_unmodified) |
216 | 217 | .at_most(:once) |
217 | 218 |
|
218 | | - result = api_client.upload(app_name, fake_binary_path, "android") |
| 219 | + result = api_client.upload(app_name, fake_binary_path, "android", upload_timeout) |
219 | 220 | expect(result).to eq(release_name) |
220 | 221 | end |
221 | 222 |
|
222 | 223 | it 'uploads the app binary for an existing updated binary' do |
223 | 224 | expect(api_client).to receive(:upload_binary) |
224 | | - .with(app_name, fake_binary_path, "android") |
| 225 | + .with(app_name, fake_binary_path, "android", upload_timeout) |
225 | 226 | .and_return(operation_name) |
226 | 227 | .at_most(:once) |
227 | 228 | expect(api_client).to receive(:get_upload_status) |
|
233 | 234 | .and_return(upload_status_response_release_updated) |
234 | 235 | .at_most(:once) |
235 | 236 |
|
236 | | - result = api_client.upload(app_name, fake_binary_path, "android") |
| 237 | + result = api_client.upload(app_name, fake_binary_path, "android", upload_timeout) |
237 | 238 | expect(result).to eq(release_name) |
238 | 239 | end |
239 | 240 |
|
|
242 | 243 | stub_const("Fastlane::Client::FirebaseAppDistributionApiClient::MAX_POLLING_RETRIES", max_polling_retries) |
243 | 244 |
|
244 | 245 | expect(api_client).to receive(:upload_binary) |
245 | | - .with(app_name, fake_binary_path, "android") |
| 246 | + .with(app_name, fake_binary_path, "android", upload_timeout) |
246 | 247 | .and_return(operation_name) |
247 | 248 | expect(api_client).to receive(:get_upload_status) |
248 | 249 | .with(operation_name) |
249 | 250 | .and_return(upload_status_response_in_progress) |
250 | 251 | .exactly(max_polling_retries + 1).times # adding 1 for initial call |
251 | 252 |
|
252 | 253 | expect do |
253 | | - api_client.upload(app_name, fake_binary_path, "android") |
| 254 | + api_client.upload(app_name, fake_binary_path, "android", upload_timeout) |
254 | 255 | end.to raise_error |
255 | 256 | end |
256 | 257 |
|
|
259 | 260 | stub_const("Fastlane::Client::FirebaseAppDistributionApiClient::MAX_POLLING_RETRIES", max_polling_retries) |
260 | 261 |
|
261 | 262 | expect(api_client).to receive(:upload_binary) |
262 | | - .with(app_name, fake_binary_path, "android") |
| 263 | + .with(app_name, fake_binary_path, "android", upload_timeout) |
263 | 264 | .and_return(operation_name) |
264 | 265 | .at_most(:once) |
265 | 266 | # return in_progress for a couple polls |
|
271 | 272 | .with(operation_name) |
272 | 273 | .and_return(upload_status_response_success) |
273 | 274 |
|
274 | | - result = api_client.upload(app_name, fake_binary_path, "android") |
| 275 | + result = api_client.upload(app_name, fake_binary_path, "android", upload_timeout) |
275 | 276 | expect(result).to eq(release_name) |
276 | 277 | end |
277 | 278 |
|
278 | 279 | it 'crashes after failing to upload with status error' do |
279 | 280 | expect(api_client).to receive(:upload_binary) |
280 | | - .with(app_name, fake_binary_path, "android") |
| 281 | + .with(app_name, fake_binary_path, "android", upload_timeout) |
281 | 282 | .and_return(operation_name) |
282 | 283 | expect(api_client).to receive(:get_upload_status) |
283 | 284 | .with(operation_name) |
284 | 285 | .and_return(upload_status_response_error) |
285 | 286 | .at_most(:once) |
286 | 287 |
|
287 | | - expect { api_client.upload(app_name, fake_binary_path, "android") } |
| 288 | + expect { api_client.upload(app_name, fake_binary_path, "android", upload_timeout) } |
288 | 289 | .to raise_error("#{ErrorMessage.upload_binary_error('APK')}: #{upload_status_response_error.error_message}") |
289 | 290 | end |
290 | 291 |
|
291 | 292 | it 'crashes after failing to upload with status unspecified' do |
292 | 293 | expect(api_client).to receive(:upload_binary) |
293 | | - .with(app_name, fake_binary_path, "android") |
| 294 | + .with(app_name, fake_binary_path, "android", upload_timeout) |
294 | 295 | .and_return(operation_name) |
295 | 296 | expect(api_client).to receive(:get_upload_status) |
296 | 297 | .with(operation_name) |
297 | 298 | .and_return(upload_status_response_status_unspecified) |
298 | 299 | .at_most(:once) |
299 | 300 |
|
300 | | - expect { api_client.upload(app_name, fake_binary_path, "android") } |
| 301 | + expect { api_client.upload(app_name, fake_binary_path, "android", upload_timeout) } |
301 | 302 | .to raise_error(ErrorMessage.upload_binary_error("APK")) |
302 | 303 | end |
303 | 304 | end |
|
0 commit comments