diff options
author | Reuben Pereira <rpereira@gitlab.com> | 2019-03-29 14:53:40 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-29 14:53:40 +0000 |
commit | c558d72b5bca44984c32b6f65f4b56332ee828f6 (patch) | |
tree | 7d03939699cb6915f2c6e00aaa53f0e25df1b0c2 /spec/models | |
parent | bf48b071f9c19c6585eb3e589bb8bc2ab6a75723 (diff) | |
download | gitlab-ce-c558d72b5bca44984c32b6f65f4b56332ee828f6.tar.gz |
Handle missing keys in sentry api response
- Do not raise error when there are missing non-essential keys in sentry
api response.
- Add specs for to check for missing keys behavior.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/error_tracking/project_error_tracking_setting_spec.rb | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb index cbde13a2c7a..21e381d9fb7 100644 --- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -167,7 +167,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do end end - context 'when sentry client raises exception' do + context 'when sentry client raises Sentry::Client::Error' do let(:sentry_client) { spy(:sentry_client) } before do @@ -179,7 +179,31 @@ describe ErrorTracking::ProjectErrorTrackingSetting do end it 'returns error' do - expect(result).to eq(error: 'error message') + expect(result).to eq( + error: 'error message', + error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE + ) + expect(subject).to have_received(:sentry_client) + expect(sentry_client).to have_received(:list_issues) + end + end + + context 'when sentry client raises Sentry::Client::MissingKeysError' do + let(:sentry_client) { spy(:sentry_client) } + + before do + synchronous_reactive_cache(subject) + + allow(subject).to receive(:sentry_client).and_return(sentry_client) + allow(sentry_client).to receive(:list_issues).with(opts) + .and_raise(Sentry::Client::MissingKeysError, 'Sentry API response is missing keys. key not found: "id"') + end + + it 'returns error' do + expect(result).to eq( + error: 'Sentry API response is missing keys. key not found: "id"', + error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_MISSING_KEYS + ) expect(subject).to have_received(:sentry_client) expect(sentry_client).to have_received(:list_issues) end |