diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-06-01 17:27:35 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-06-06 01:09:10 +0300 |
commit | 810866ecb6c7be4fdac88dc3b2a6cd9ad49ac7bf (patch) | |
tree | 20c8292a1527918b71b2c099e6c49598e65d8598 /spec/workers/repository_fork_worker_spec.rb | |
parent | f07aee72bef4604312e11a43fce3a47865bce100 (diff) |
backports changed import logic from pull mirroring feature into CE
Diffstat (limited to 'spec/workers/repository_fork_worker_spec.rb')
-rw-r--r-- | spec/workers/repository_fork_worker_spec.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index 5e1cb74c7fc..6ea5569b438 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe RepositoryForkWorker do - let(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository, :import_scheduled) } let(:fork_project) { create(:project, :repository, forked_from_project: project) } let(:shell) { Gitlab::Shell.new } @@ -46,15 +46,27 @@ describe RepositoryForkWorker do end it "handles bad fork" do + source_path = project.full_path + target_path = fork_project.namespace.full_path + error_message = "Unable to fork project #{project.id} for repository #{source_path} -> #{target_path}" + expect(shell).to receive(:fork_repository).and_return(false) - expect(subject.logger).to receive(:error) + expect do + subject.perform(project.id, '/test/path', source_path, target_path) + end.to raise_error(RepositoryForkWorker::ForkError, error_message) + end - subject.perform( - project.id, - '/test/path', - project.full_path, - fork_project.namespace.full_path) + it 'handles unexpected error' do + source_path = project.full_path + target_path = fork_project.namespace.full_path + + allow_any_instance_of(Gitlab::Shell).to receive(:fork_repository).and_raise(RuntimeError) + + expect do + subject.perform(project.id, '/test/path', source_path, target_path) + end.to raise_error(RepositoryForkWorker::ForkError) + expect(project.reload.import_status).to eq('failed') end end end |