diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-10-18 21:46:05 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-07 23:25:03 +0100 |
commit | 6e242e82237ad2cf362098f3f42f4a9dd1a4ad27 (patch) | |
tree | 415639ff14183a4914dac69fcc400806cb477525 /spec/services | |
parent | 4dfe26cd8b6863b7e6c81f5c280cdafe9b6e17b6 (diff) | |
download | gitlab-ce-github-importer-refactor.tar.gz |
Replace old GH importer with the parallel importergithub-importer-refactor
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/projects/import_service_spec.rb | 48 |
1 files changed, 13 insertions, 35 deletions
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 |