diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/lib/gitlab/bulk_import/client_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/lib/gitlab/bulk_import/client_spec.rb')
-rw-r--r-- | spec/lib/gitlab/bulk_import/client_spec.rb | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/spec/lib/gitlab/bulk_import/client_spec.rb b/spec/lib/gitlab/bulk_import/client_spec.rb deleted file mode 100644 index a6f8dd6d194..00000000000 --- a/spec/lib/gitlab/bulk_import/client_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::BulkImport::Client do - include ImportSpecHelper - - let(:uri) { 'http://gitlab.example' } - let(:token) { 'token' } - let(:resource) { 'resource' } - - subject { described_class.new(uri: uri, token: token) } - - describe '#get' do - let(:response_double) { double(code: 200, success?: true, parsed_response: {}) } - - shared_examples 'performs network request' do - it 'performs network request' do - expect(Gitlab::HTTP).to receive(:get).with(*expected_args).and_return(response_double) - - subject.get(resource) - end - end - - describe 'parsed response' do - it 'returns parsed response' do - response_double = double(code: 200, success?: true, parsed_response: [{ id: 1 }, { id: 2 }]) - - allow(Gitlab::HTTP).to receive(:get).and_return(response_double) - - expect(subject.get(resource)).to eq(response_double.parsed_response) - end - end - - describe 'request query' do - include_examples 'performs network request' do - let(:expected_args) do - [ - anything, - hash_including( - query: { - page: described_class::DEFAULT_PAGE, - per_page: described_class::DEFAULT_PER_PAGE - } - ) - ] - end - end - end - - describe 'request headers' do - include_examples 'performs network request' do - let(:expected_args) do - [ - anything, - hash_including( - headers: { - 'Content-Type' => 'application/json', - 'Authorization' => "Bearer #{token}" - } - ) - ] - end - end - end - - describe 'request uri' do - include_examples 'performs network request' do - let(:expected_args) do - ['http://gitlab.example:80/api/v4/resource', anything] - end - end - end - - context 'error handling' do - context 'when error occurred' do - it 'raises ConnectionError' do - allow(Gitlab::HTTP).to receive(:get).and_raise(Errno::ECONNREFUSED) - - expect { subject.get(resource) }.to raise_exception(described_class::ConnectionError) - end - end - - context 'when response is not success' do - it 'raises ConnectionError' do - response_double = double(code: 503, success?: false) - - allow(Gitlab::HTTP).to receive(:get).and_return(response_double) - - expect { subject.get(resource) }.to raise_exception(described_class::ConnectionError) - end - end - end - end -end |