diff options
Diffstat (limited to 'spec/lib/gitlab/github_import/importer/repository_importer_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import/importer/repository_importer_spec.rb | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb index 3839303b881..58a8fb1b7e4 100644 --- a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb @@ -202,7 +202,7 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do expect(repository) .to receive(:fetch_as_mirror) - .with(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: true, remote_name: 'github') + .with(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: true) service = double expect(Repositories::HousekeepingService) @@ -211,17 +211,6 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do expect(importer.import_repository).to eq(true) end - - it 'marks the import as failed when an error was raised' do - expect(project).to receive(:ensure_repository) - .and_raise(Gitlab::Git::Repository::NoRepository) - - expect(importer) - .to receive(:fail_import) - .and_return(false) - - expect(importer.import_repository).to eq(false) - end end describe '#import_wiki_repository' do @@ -234,28 +223,40 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do expect(importer.import_wiki_repository).to eq(true) end - it 'marks the import as failed and creates an empty repo if an error was raised' do - expect(wiki_repository) - .to receive(:import_repository) - .with(importer.wiki_url) - .and_raise(Gitlab::Git::CommandError) + context 'when it raises a Gitlab::Git::CommandError' do + context 'when the error is not a "repository not exported"' do + it 'creates the wiki and re-raise the exception' do + exception = Gitlab::Git::CommandError.new - expect(importer) - .to receive(:fail_import) - .and_return(false) + expect(wiki_repository) + .to receive(:import_repository) + .with(importer.wiki_url) + .and_raise(exception) - expect(project) - .to receive(:create_wiki) + expect(project) + .to receive(:create_wiki) - expect(importer.import_wiki_repository).to eq(false) - end - end + expect { importer.import_wiki_repository } + .to raise_error(exception) + end + end + + context 'when the error is a "repository not exported"' do + it 'returns true' do + exception = Gitlab::Git::CommandError.new('repository not exported') - describe '#fail_import' do - it 'marks the import as failed' do - expect(project.import_state).to receive(:mark_as_failed).with('foo') + expect(wiki_repository) + .to receive(:import_repository) + .with(importer.wiki_url) + .and_raise(exception) - expect(importer.fail_import('foo')).to eq(false) + expect(project) + .not_to receive(:create_wiki) + + expect(importer.import_wiki_repository) + .to eq(true) + end + end end end |