Skip to content

Commit 1368924

Browse files
committed
Add test for current metadata_download_helper behavior
1 parent a0b906d commit 1368924

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

spec/metadata_download_helper_spec.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

0 commit comments

Comments
 (0)