Merge pull request #10905 from tchak/fix-api-entreprise-sentry-error

ETQ Usager, je veux pouvoir déposer mon dossier même si le service des SIRET n'est pas disponible
This commit is contained in:
Colin Darie 2024-10-09 14:13:47 +00:00 committed by GitHub
commit 9ef445a4a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 55 additions and 3 deletions

View file

@ -0,0 +1,3 @@
{
"errors": [{ "code": "01000" }]
}

View file

@ -0,0 +1,3 @@
{
"errors": [{ "code": "01001" }]
}

View file

@ -0,0 +1,3 @@
{
"errors": [{ "code": "01002" }]
}

View file

@ -24,6 +24,36 @@ describe APIEntreprise::API do
end
end
context 'when the service reponds with 01000 code' do
let(:siren) { '111111111' }
let(:status) { 502 }
let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/error_code_01000.json').read }
it 'raises APIEntreprise::API::Error::RequestFailed' do
expect { subject }.to raise_error(APIEntreprise::API::Error::ServiceUnavailable)
end
end
context 'when the service reponds with 01001 code' do
let(:siren) { '111111111' }
let(:status) { 502 }
let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/error_code_01001.json').read }
it 'raises APIEntreprise::API::Error::RequestFailed' do
expect { subject }.to raise_error(APIEntreprise::API::Error::ServiceUnavailable)
end
end
context 'when the service reponds with 01002 code' do
let(:siren) { '111111111' }
let(:status) { 504 }
let(:body) { Rails.root.join('spec/fixtures/files/api_entreprise/error_code_01002.json').read }
it 'raises APIEntreprise::API::Error::RequestFailed' do
expect { subject }.to raise_error(APIEntreprise::API::Error::ServiceUnavailable)
end
end
context 'when siren does not exist' do
let(:siren) { '111111111' }
let(:status) { 404 }