diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/github/client_spec.rb | 34 | ||||
-rw-r--r-- | spec/lib/github/import/legacy_diff_note_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/github/import/note_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/import_sources_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/projects/import_service_spec.rb | 48 |
5 files changed, 14 insertions, 88 deletions
diff --git a/spec/lib/github/client_spec.rb b/spec/lib/github/client_spec.rb deleted file mode 100644 index b846096fe25..00000000000 --- a/spec/lib/github/client_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe Github::Client do - let(:connection) { spy } - let(:rate_limit) { double(get: [false, 1]) } - let(:client) { described_class.new({}) } - let(:results) { double } - let(:response) { double } - - before do - allow(Faraday).to receive(:new).and_return(connection) - allow(Github::RateLimit).to receive(:new).with(connection).and_return(rate_limit) - end - - describe '#get' do - before do - allow(Github::Response).to receive(:new).with(results).and_return(response) - end - - it 'uses a default per_page param' do - expect(connection).to receive(:get).with('/foo', per_page: 100).and_return(results) - - expect(client.get('/foo')).to eq(response) - end - - context 'with per_page given' do - it 'overwrites the default per_page' do - expect(connection).to receive(:get).with('/foo', per_page: 30).and_return(results) - - expect(client.get('/foo', per_page: 30)).to eq(response) - end - end - end -end diff --git a/spec/lib/github/import/legacy_diff_note_spec.rb b/spec/lib/github/import/legacy_diff_note_spec.rb deleted file mode 100644 index 8c50b46cacb..00000000000 --- a/spec/lib/github/import/legacy_diff_note_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'spec_helper' - -describe Github::Import::LegacyDiffNote do - describe '#type' do - it 'returns the original note type' do - expect(described_class.new.type).to eq('LegacyDiffNote') - end - end -end diff --git a/spec/lib/github/import/note_spec.rb b/spec/lib/github/import/note_spec.rb deleted file mode 100644 index fcdccd9e097..00000000000 --- a/spec/lib/github/import/note_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'spec_helper' - -describe Github::Import::Note do - describe '#type' do - it 'returns the original note type' do - expect(described_class.new.type).to eq('Note') - end - end -end diff --git a/spec/lib/gitlab/import_sources_spec.rb b/spec/lib/gitlab/import_sources_spec.rb index 9d7473120b5..f2fa315e3ec 100644 --- a/spec/lib/gitlab/import_sources_spec.rb +++ b/spec/lib/gitlab/import_sources_spec.rb @@ -56,7 +56,7 @@ describe Gitlab::ImportSources do describe '.importer' do import_sources = { - 'github' => Github::Import, + 'github' => Gitlab::GithubImport::ParallelImporter, 'bitbucket' => Gitlab::BitbucketImport::Importer, 'gitlab' => Gitlab::GitlabImport::Importer, 'google_code' => Gitlab::GoogleCodeImport::Importer, diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index 29b221564fe..bf7facaec99 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -72,21 +72,24 @@ describe Projects::ImportService do end context 'with a Github repository' do - it 'succeeds if repository import is successfully' do - expect_any_instance_of(Github::Import).to receive(:execute).and_return(true) + it 'succeeds if repository import was scheduled' do + expect_any_instance_of(Gitlab::GithubImport::ParallelImporter) + .to receive(:execute) + .and_return(true) result = subject.execute expect(result[:status]).to eq :success end - it 'fails if repository import fails' do - expect_any_instance_of(Repository).to receive(:fetch_remote).and_raise(Gitlab::Shell::Error.new('Failed to import the repository')) + it 'fails if repository import was not scheduled' do + expect_any_instance_of(Gitlab::GithubImport::ParallelImporter) + .to receive(:execute) + .and_return(false) result = subject.execute expect(result[:status]).to eq :error - expect(result[:message]).to eq "Error importing repository #{project.import_url} into #{project.path_with_namespace} - The remote data could not be imported." end end @@ -127,47 +130,22 @@ describe Projects::ImportService do end it 'succeeds if importer succeeds' do - allow_any_instance_of(Github::Import).to receive(:execute).and_return(true) + allow_any_instance_of(Gitlab::GithubImport::ParallelImporter) + .to receive(:execute).and_return(true) result = subject.execute expect(result[:status]).to eq :success end - it 'flushes various caches' do - allow_any_instance_of(Github::Import).to receive(:execute) - .and_return(true) - - expect_any_instance_of(Repository).to receive(:expire_content_cache) - - subject.execute - end - it 'fails if importer fails' do - allow_any_instance_of(Github::Import).to receive(:execute).and_return(false) - - result = subject.execute - - expect(result[:status]).to eq :error - expect(result[:message]).to eq "Error importing repository #{project.import_url} into #{project.full_path} - The remote data could not be imported." - end - - it 'fails if importer raise an error' do - allow_any_instance_of(Github::Import).to receive(:execute).and_raise(Projects::ImportService::Error.new('Github: failed to connect API')) + allow_any_instance_of(Gitlab::GithubImport::ParallelImporter) + .to receive(:execute) + .and_return(false) result = subject.execute expect(result[:status]).to eq :error - expect(result[:message]).to eq "Error importing repository #{project.import_url} into #{project.full_path} - Github: failed to connect API" - end - - it 'expires content cache after error' do - allow_any_instance_of(Project).to receive(:repository_exists?).and_return(false) - - expect_any_instance_of(Repository).to receive(:fetch_remote).and_raise(Gitlab::Shell::Error.new) - expect_any_instance_of(Repository).to receive(:expire_content_cache) - - subject.execute end end |