summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/repo_restorer_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/import_export/repo_restorer_spec.rb')
-rw-r--r--spec/lib/gitlab/import_export/repo_restorer_spec.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/spec/lib/gitlab/import_export/repo_restorer_spec.rb b/spec/lib/gitlab/import_export/repo_restorer_spec.rb
index ace4449042e..b32ae60fbcc 100644
--- a/spec/lib/gitlab/import_export/repo_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/repo_restorer_spec.rb
@@ -36,21 +36,20 @@ RSpec.describe Gitlab::ImportExport::RepoRestorer do
expect(subject.restore).to be_truthy
end
- context 'when the repository creation fails' do
- before do
- allow_next_instance_of(Repositories::DestroyService) do |instance|
+ context 'when the repository already exists' do
+ it 'deletes the existing repository before importing' do
+ allow(project.repository).to receive(:exists?).and_return(true)
+ allow(project.repository).to receive(:path).and_return('repository_path')
+
+ expect_next_instance_of(Repositories::DestroyService) do |instance|
expect(instance).to receive(:execute).and_call_original
end
- end
-
- it 'logs the error' do
- allow(project.repository)
- .to receive(:create_from_bundle)
- .and_raise('9:CreateRepositoryFromBundle: target directory is non-empty')
- expect(shared).to receive(:error).and_call_original
+ expect(shared.logger).to receive(:info).with(
+ message: 'Deleting existing "repository_path" to re-import it.'
+ )
- expect(subject.restore).to be_falsey
+ expect(subject.restore).to be_truthy
end
end
end