blob: 2b76f0e27c922f1c5b8da6c4ab82e6e3c8781295 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# frozen_string_literal: true
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
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)
end
described_class::SEQUENTIAL_IMPORTERS.each do |klass|
instance = double(:instance)
expect(klass).to receive(:new)
.with(project, importer.client)
.and_return(instance)
expect(instance).to receive(:execute)
end
described_class::PARALLEL_IMPORTERS.each do |klass|
instance = double(:instance)
expect(klass).to receive(:new)
.with(project, importer.client, parallel: false)
.and_return(instance)
expect(instance).to receive(:execute)
end
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
|