Skip to content

Commit 6e262dd

Browse files
committed
Add test for GlotPress 429 with manual retry
1 parent 0497006 commit 6e262dd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

spec/glotpress_downloader_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,30 @@
5555
end
5656
end
5757
end
58+
59+
context 'when auto retry is disabled' do
60+
context 'when GlotPress returs a 429 code' do
61+
it 'prompt the user for confirmation, ignoring the max auto retry parameter' do
62+
sleep_time = 0.1
63+
max_retries = 2
64+
downloader = described_class.new(auto_retry: false, auto_retry_sleep_time: sleep_time, auto_retry_max_attempts: max_retries)
65+
fake_url = 'https://test.com'
66+
67+
stub_request(:get, fake_url).to_return(status: 429, body: 'Too Many Requests')
68+
69+
count = 0
70+
allow(Fastlane::UI).to receive(:confirm).with("Retry downloading `#{fake_url}` after receiving 429 from the API?") do
71+
count += 1
72+
# Simulate user retrying more times that the max retries, then aborting
73+
count <= max_retries
74+
end
75+
76+
# When the user aborts, with finish with an error
77+
expect(Fastlane::UI).to receive(:error).with(/Abandoning `#{fake_url}` download as requested./)
78+
79+
downloader.download(fake_url)
80+
end
81+
end
82+
end
5883
end
5984
end

0 commit comments

Comments
 (0)