diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /spec/lib/gitlab/github_import/sequential_importer_spec.rb | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/lib/gitlab/github_import/sequential_importer_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import/sequential_importer_spec.rb | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/spec/lib/gitlab/github_import/sequential_importer_spec.rb b/spec/lib/gitlab/github_import/sequential_importer_spec.rb index 3c3f8ff59d0..2b76f0e27c9 100644 --- a/spec/lib/gitlab/github_import/sequential_importer_spec.rb +++ b/spec/lib/gitlab/github_import/sequential_importer_spec.rb @@ -4,10 +4,17 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport::SequentialImporter do describe '#execute' do + let_it_be(:project) do + create(:project, import_url: 'http://t0ken@github.another-domain.com/repo-org/repo.git', import_type: 'github') + end + + subject(:importer) { described_class.new(project, token: 'foo') } + it 'imports a project in sequence' do - repository = double(:repository) - project = double(:project, id: 1, repository: repository, import_url: 'http://t0ken@github.another-domain.com/repo-org/repo.git', group: nil) - importer = described_class.new(project, token: 'foo') + expect_next_instance_of(Gitlab::Import::Metrics) do |instance| + expect(instance).to receive(:track_start_import) + expect(instance).to receive(:track_finished_import) + end expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance| expect(instance).to receive(:execute) @@ -35,5 +42,23 @@ RSpec.describe Gitlab::GithubImport::SequentialImporter do expect(importer.execute).to eq(true) end + + it 'raises an error' do + exception = StandardError.new('_some_error_') + + expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |importer| + expect(importer).to receive(:execute).and_raise(exception) + end + expect(Gitlab::Import::ImportFailureService).to receive(:track) + .with( + project_id: project.id, + exception: exception, + error_source: described_class.name, + fail_import: true, + metrics: true + ).and_call_original + + expect { importer.execute }.to raise_error(StandardError) + end end end |