diff options
Diffstat (limited to 'spec/lib/gitlab/http_spec.rb')
-rw-r--r-- | spec/lib/gitlab/http_spec.rb | 56 |
1 files changed, 7 insertions, 49 deletions
diff --git a/spec/lib/gitlab/http_spec.rb b/spec/lib/gitlab/http_spec.rb index c2fb987d195..929fd37ee40 100644 --- a/spec/lib/gitlab/http_spec.rb +++ b/spec/lib/gitlab/http_spec.rb @@ -83,67 +83,25 @@ RSpec.describe Gitlab::HTTP do subject(:request_slow_responder) { described_class.post('http://example.org', **options) } - shared_examples 'tracks the timeout but does not raise an error' do - specify :aggregate_failures do - expect(Gitlab::ErrorTracking).to receive(:track_exception).with( - an_instance_of(Gitlab::HTTP::ReadTotalTimeout) - ).once - - expect { request_slow_responder }.not_to raise_error - end - - it 'still calls the block' do - expect { |b| described_class.post('http://example.org', **options, &b) }.to yield_successive_args('a', 'b') - end - end - - shared_examples 'does not track or raise timeout error' do - specify :aggregate_failures do - expect(Gitlab::ErrorTracking).not_to receive(:track_exception) - - expect { request_slow_responder }.not_to raise_error - end - end - - it_behaves_like 'tracks the timeout but does not raise an error' - - context 'and use_read_total_timeout option is truthy' do - let(:options) { { use_read_total_timeout: true } } - - it 'raises an error' do - expect { request_slow_responder }.to raise_error(Gitlab::HTTP::ReadTotalTimeout, /Request timed out after ?([0-9]*[.])?[0-9]+ seconds/) - end + it 'raises an error' do + expect { request_slow_responder }.to raise_error(Gitlab::HTTP::ReadTotalTimeout, /Request timed out after ?([0-9]*[.])?[0-9]+ seconds/) end context 'and timeout option is greater than DEFAULT_READ_TOTAL_TIMEOUT' do let(:options) { { timeout: 10.seconds } } - it_behaves_like 'does not track or raise timeout error' + it 'does not raise an error' do + expect { request_slow_responder }.not_to raise_error + end end context 'and stream_body option is truthy' do let(:options) { { stream_body: true } } - it_behaves_like 'does not track or raise timeout error' - - context 'but skip_read_total_timeout option is falsey' do - let(:options) { { stream_body: true, skip_read_total_timeout: false } } - - it_behaves_like 'tracks the timeout but does not raise an error' + it 'does not raise an error' do + expect { request_slow_responder }.not_to raise_error end end - - context 'and skip_read_total_timeout option is truthy' do - let(:options) { { skip_read_total_timeout: true } } - - it_behaves_like 'does not track or raise timeout error' - end - - context 'and skip_read_total_timeout option is falsely' do - let(:options) { { skip_read_total_timeout: false } } - - it_behaves_like 'tracks the timeout but does not raise an error' - end end it 'calls a block' do |