[#5675] for all api entreprise job, retry on 502, 503

This commit is contained in:
simon lehericey 2020-12-02 17:17:00 +01:00
parent 02e7de0003
commit 9eab310565
8 changed files with 59 additions and 22 deletions

View file

@ -12,13 +12,13 @@ describe ApiEntreprise::API do
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
end
context 'when the service is unavailable' do
context 'when the service throws a bad gateaway exception' do
let(:siren) { '111111111' }
let(:status) { 502 }
let(:body) { File.read('spec/fixtures/files/api_entreprise/entreprises_unavailable.json') }
it 'raises ApiEntreprise::API::RequestFailed' do
expect { subject }.to raise_error(ApiEntreprise::API::RequestFailed)
expect { subject }.to raise_error(ApiEntreprise::API::BadGateway)
end
end

View file

@ -81,7 +81,7 @@ describe ApiEntreprise::EntrepriseAdapter do
context "when the service is unavailable" do
let(:body) { File.read('spec/fixtures/files/api_entreprise/entreprises_unavailable.json') }
let(:status) { 502 }
let(:status) { 500 }
it 'raises an exception' do
expect { subject }.to raise_error(ApiEntreprise::API::RequestFailed)