File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ describe Fastlane ::Helper ::MetadataDownloader do
4
+ describe 'downloading from GlotPress' do
5
+ context 'when GlotPress returs a 429 code' do
6
+ it 'automatically retries' do
7
+ in_tmp_dir do |tmp_dir |
8
+ metadata_downaloder = described_class . new (
9
+ tmp_dir ,
10
+ { key : { desc : 'target-file-name.txt' } } ,
11
+ true
12
+ )
13
+
14
+ fake_url = 'https://test.com'
15
+
16
+ count = 0
17
+ stub_request ( :get , fake_url ) . to_return do
18
+ count += 1
19
+ if count == 1
20
+ { status : 429 , body : 'Too Many Requests' }
21
+ else
22
+ { status : 200 , body : 'OK' }
23
+ end
24
+ end
25
+
26
+ expect ( Fastlane ::UI ) . to receive ( :message )
27
+ . with ( /Received 429 for `en-AU`. Auto retrying in 20 seconds.../ )
28
+
29
+ expect ( Fastlane ::UI ) . to receive ( :message )
30
+ . with ( /No translation available for en-AU/ )
31
+
32
+ expect ( Fastlane ::UI ) . to receive ( :success )
33
+ . with ( /Successfully downloaded `en-AU`./ )
34
+
35
+ metadata_downaloder . download ( 'en-AU' , fake_url , false )
36
+
37
+ expect ( count ) . to eq ( 2 )
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
You can’t perform that action at this time.
0 commit comments