diff options
author | Reuben Pereira <rpereira@gitlab.com> | 2019-03-29 17:53:40 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-29 17:53:40 +0300 |
commit | c558d72b5bca44984c32b6f65f4b56332ee828f6 (patch) | |
tree | 7d03939699cb6915f2c6e00aaa53f0e25df1b0c2 /spec/services/error_tracking | |
parent | bf48b071f9c19c6585eb3e589bb8bc2ab6a75723 (diff) |
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/services/error_tracking')
-rw-r--r-- | spec/services/error_tracking/list_issues_service_spec.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/services/error_tracking/list_issues_service_spec.rb b/spec/services/error_tracking/list_issues_service_spec.rb index 9d4fc62f923..3a8f3069911 100644 --- a/spec/services/error_tracking/list_issues_service_spec.rb +++ b/spec/services/error_tracking/list_issues_service_spec.rb @@ -53,7 +53,10 @@ describe ErrorTracking::ListIssuesService do before do allow(error_tracking_setting) .to receive(:list_sentry_issues) - .and_return(error: 'Sentry response status code: 401') + .and_return( + error: 'Sentry response status code: 401', + error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE + ) end it 'returns the error' do @@ -64,6 +67,25 @@ describe ErrorTracking::ListIssuesService do ) end end + + context 'when list_sentry_issues returns error with http_status' do + before do + allow(error_tracking_setting) + .to receive(:list_sentry_issues) + .and_return( + error: 'Sentry API response is missing keys. key not found: "id"', + error_type: ErrorTracking::ProjectErrorTrackingSetting::SENTRY_API_ERROR_TYPE_MISSING_KEYS + ) + end + + it 'returns the error with correct http_status' do + expect(result).to eq( + status: :error, + http_status: :internal_server_error, + message: 'Sentry API response is missing keys. key not found: "id"' + ) + end + end end context 'with unauthorized user' do |