Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/gitlab/github_import')
-rw-r--r--spec/workers/gitlab/github_import/attachments/import_issue_worker_spec.rb34
-rw-r--r--spec/workers/gitlab/github_import/attachments/import_merge_request_worker_spec.rb34
-rw-r--r--spec/workers/gitlab/github_import/attachments/import_note_worker_spec.rb49
-rw-r--r--spec/workers/gitlab/github_import/attachments/import_release_worker_spec.rb49
-rw-r--r--spec/workers/gitlab/github_import/import_issue_worker_spec.rb11
-rw-r--r--spec/workers/gitlab/github_import/import_release_attachments_worker_spec.rb6
-rw-r--r--spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb60
-rw-r--r--spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb46
-rw-r--r--spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb44
-rw-r--r--spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb45
-rw-r--r--spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb71
11 files changed, 326 insertions, 123 deletions
diff --git a/spec/workers/gitlab/github_import/attachments/import_issue_worker_spec.rb b/spec/workers/gitlab/github_import/attachments/import_issue_worker_spec.rb
new file mode 100644
index 00000000000..6d617755861
--- /dev/null
+++ b/spec/workers/gitlab/github_import/attachments/import_issue_worker_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::GithubImport::Attachments::ImportIssueWorker do
+ subject(:worker) { described_class.new }
+
+ describe '#import' do
+ let(:import_state) { create(:import_state, :started) }
+
+ let(:project) do
+ instance_double('Project', full_path: 'foo/bar', id: 1, import_state: import_state)
+ end
+
+ let(:client) { instance_double('Gitlab::GithubImport::Client') }
+
+ it 'imports an issue attachments' do
+ expect_next_instance_of(
+ Gitlab::GithubImport::Importer::NoteAttachmentsImporter,
+ an_instance_of(Gitlab::GithubImport::Representation::NoteText),
+ project,
+ client
+ ) do |note_attachments_importer|
+ expect(note_attachments_importer).to receive(:execute)
+ end
+
+ expect(Gitlab::GithubImport::ObjectCounter)
+ .to receive(:increment)
+ .and_call_original
+
+ worker.import(project, client, {})
+ end
+ end
+end
diff --git a/spec/workers/gitlab/github_import/attachments/import_merge_request_worker_spec.rb b/spec/workers/gitlab/github_import/attachments/import_merge_request_worker_spec.rb
new file mode 100644
index 00000000000..66dfc027e6e
--- /dev/null
+++ b/spec/workers/gitlab/github_import/attachments/import_merge_request_worker_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::GithubImport::Attachments::ImportMergeRequestWorker do
+ subject(:worker) { described_class.new }
+
+ describe '#import' do
+ let(:import_state) { create(:import_state, :started) }
+
+ let(:project) do
+ instance_double('Project', full_path: 'foo/bar', id: 1, import_state: import_state)
+ end
+
+ let(:client) { instance_double('Gitlab::GithubImport::Client') }
+
+ it 'imports an merge request attachments' do
+ expect_next_instance_of(
+ Gitlab::GithubImport::Importer::NoteAttachmentsImporter,
+ an_instance_of(Gitlab::GithubImport::Representation::NoteText),
+ project,
+ client
+ ) do |note_attachments_importer|
+ expect(note_attachments_importer).to receive(:execute)
+ end
+
+ expect(Gitlab::GithubImport::ObjectCounter)
+ .to receive(:increment)
+ .and_call_original
+
+ worker.import(project, client, {})
+ end
+ end
+end
diff --git a/spec/workers/gitlab/github_import/attachments/import_note_worker_spec.rb b/spec/workers/gitlab/github_import/attachments/import_note_worker_spec.rb
new file mode 100644
index 00000000000..7b60cdecca6
--- /dev/null
+++ b/spec/workers/gitlab/github_import/attachments/import_note_worker_spec.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::GithubImport::Attachments::ImportNoteWorker do
+ subject(:worker) { described_class.new }
+
+ describe '#import' do
+ let(:import_state) { create(:import_state, :started) }
+
+ let(:project) do
+ instance_double('Project', full_path: 'foo/bar', id: 1, import_state: import_state)
+ end
+
+ let(:client) { instance_double('Gitlab::GithubImport::Client') }
+ let(:importer) { instance_double('Gitlab::GithubImport::Importer::NoteAttachmentsImporter') }
+
+ let(:note_hash) do
+ {
+ 'record_db_id' => rand(100),
+ 'record_type' => 'Note',
+ 'text' => <<-TEXT
+ Some text...
+
+ ![special-image](https://user-images.githubusercontent.com...)
+ TEXT
+ }
+ end
+
+ it 'imports an release attachments' do
+ expect(Gitlab::GithubImport::Importer::NoteAttachmentsImporter)
+ .to receive(:new)
+ .with(
+ an_instance_of(Gitlab::GithubImport::Representation::NoteText),
+ project,
+ client
+ )
+ .and_return(importer)
+
+ expect(importer).to receive(:execute)
+
+ expect(Gitlab::GithubImport::ObjectCounter)
+ .to receive(:increment)
+ .and_call_original
+
+ worker.import(project, client, note_hash)
+ end
+ end
+end
diff --git a/spec/workers/gitlab/github_import/attachments/import_release_worker_spec.rb b/spec/workers/gitlab/github_import/attachments/import_release_worker_spec.rb
new file mode 100644
index 00000000000..e49b2fb6504
--- /dev/null
+++ b/spec/workers/gitlab/github_import/attachments/import_release_worker_spec.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::GithubImport::Attachments::ImportReleaseWorker do
+ subject(:worker) { described_class.new }
+
+ describe '#import' do
+ let(:import_state) { create(:import_state, :started) }
+
+ let(:project) do
+ instance_double('Project', full_path: 'foo/bar', id: 1, import_state: import_state)
+ end
+
+ let(:client) { instance_double('Gitlab::GithubImport::Client') }
+ let(:importer) { instance_double('Gitlab::GithubImport::Importer::NoteAttachmentsImporter') }
+
+ let(:note_hash) do
+ {
+ 'record_db_id' => rand(100),
+ 'record_type' => 'Release',
+ 'text' => <<-TEXT
+ Some text...
+
+ ![special-image](https://user-images.githubusercontent.com...)
+ TEXT
+ }
+ end
+
+ it 'imports an release attachments' do
+ expect(Gitlab::GithubImport::Importer::NoteAttachmentsImporter)
+ .to receive(:new)
+ .with(
+ an_instance_of(Gitlab::GithubImport::Representation::NoteText),
+ project,
+ client
+ )
+ .and_return(importer)
+
+ expect(importer).to receive(:execute)
+
+ expect(Gitlab::GithubImport::ObjectCounter)
+ .to receive(:increment)
+ .and_call_original
+
+ worker.import(project, client, note_hash)
+ end
+ end
+end
diff --git a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb
index c2a7639fde4..ef1d2e3f3e7 100644
--- a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb
@@ -45,4 +45,15 @@ RSpec.describe Gitlab::GithubImport::ImportIssueWorker do
worker.import(project, client, hash)
end
end
+
+ describe '#increment_object_counter?' do
+ context 'when github issue is a pull request' do
+ let(:issue) { double(:issue, pull_request?: true) }
+ let(:project) { double(:project) }
+
+ it 'returns false' do
+ expect(worker).not_to be_increment_object_counter(issue)
+ end
+ end
+ end
end
diff --git a/spec/workers/gitlab/github_import/import_release_attachments_worker_spec.rb b/spec/workers/gitlab/github_import/import_release_attachments_worker_spec.rb
index cd53c6ee9c0..1d32d5c0e21 100644
--- a/spec/workers/gitlab/github_import/import_release_attachments_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/import_release_attachments_worker_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Gitlab::GithubImport::ImportReleaseAttachmentsWorker do
end
let(:client) { instance_double('Gitlab::GithubImport::Client') }
- let(:importer) { instance_double('Gitlab::GithubImport::Importer::ReleaseAttachmentsImporter') }
+ let(:importer) { instance_double('Gitlab::GithubImport::Importer::NoteAttachmentsImporter') }
let(:release_hash) do
{
@@ -27,10 +27,10 @@ RSpec.describe Gitlab::GithubImport::ImportReleaseAttachmentsWorker do
end
it 'imports an issue event' do
- expect(Gitlab::GithubImport::Importer::ReleaseAttachmentsImporter)
+ expect(Gitlab::GithubImport::Importer::NoteAttachmentsImporter)
.to receive(:new)
.with(
- an_instance_of(Gitlab::GithubImport::Representation::ReleaseAttachments),
+ an_instance_of(Gitlab::GithubImport::Representation::NoteText),
project,
client
)
diff --git a/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb
index c2c5e1dbf4e..ecfece735af 100644
--- a/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb
@@ -5,40 +5,60 @@ require 'spec_helper'
RSpec.describe Gitlab::GithubImport::Stage::ImportAttachmentsWorker do
subject(:worker) { described_class.new }
- let(:project) { create(:project) }
- let!(:group) { create(:group, projects: [project]) }
- let(:feature_flag_state) { [group] }
+ let_it_be(:project) { create(:project) }
+ let(:settings) { ::Gitlab::GithubImport::Settings.new(project) }
+ let(:stage_enabled) { true }
+
+ before do
+ settings.write({ attachments_import: stage_enabled })
+ end
describe '#import' do
- let(:importer) { instance_double('Gitlab::GithubImport::Importer::ReleasesAttachmentsImporter') }
let(:client) { instance_double('Gitlab::GithubImport::Client') }
-
- before do
- stub_feature_flags(github_importer_attachments_import: feature_flag_state)
+ let(:importers) do
+ [
+ {
+ klass: Gitlab::GithubImport::Importer::Attachments::ReleasesImporter,
+ double: instance_double('Gitlab::GithubImport::Importer::Attachments::ReleasesImporter'),
+ waiter: Gitlab::JobWaiter.new(2, '123')
+ },
+ {
+ klass: Gitlab::GithubImport::Importer::Attachments::NotesImporter,
+ double: instance_double('Gitlab::GithubImport::Importer::Attachments::NotesImporter'),
+ waiter: Gitlab::JobWaiter.new(3, '234')
+ },
+ {
+ klass: Gitlab::GithubImport::Importer::Attachments::IssuesImporter,
+ double: instance_double('Gitlab::GithubImport::Importer::Attachments::IssuesImporter'),
+ waiter: Gitlab::JobWaiter.new(4, '345')
+ },
+ {
+ klass: Gitlab::GithubImport::Importer::Attachments::MergeRequestsImporter,
+ double: instance_double('Gitlab::GithubImport::Importer::Attachments::MergeRequestsImporter'),
+ waiter: Gitlab::JobWaiter.new(5, '456')
+ }
+ ]
end
- it 'imports release attachments' do
- waiter = Gitlab::JobWaiter.new(2, '123')
-
- expect(Gitlab::GithubImport::Importer::ReleasesAttachmentsImporter)
- .to receive(:new)
- .with(project, client)
- .and_return(importer)
-
- expect(importer).to receive(:execute).and_return(waiter)
+ it 'imports attachments' do
+ importers.each do |importer|
+ expect_next_instance_of(importer[:klass], project, client) do |instance|
+ expect(instance).to receive(:execute).and_return(importer[:waiter])
+ end
+ end
expect(Gitlab::GithubImport::AdvanceStageWorker)
.to receive(:perform_async)
- .with(project.id, { '123' => 2 }, :protected_branches)
+ .with(project.id, { '123' => 2, '234' => 3, '345' => 4, '456' => 5 }, :protected_branches)
worker.import(client, project)
end
- context 'when feature flag is disabled' do
- let(:feature_flag_state) { false }
+ context 'when stage is disabled' do
+ let(:stage_enabled) { false }
it 'skips release attachments import and calls next stage' do
- expect(Gitlab::GithubImport::Importer::ReleasesAttachmentsImporter).not_to receive(:new)
+ importers.each { |importer| expect(importer[:klass]).not_to receive(:new) }
expect(Gitlab::GithubImport::AdvanceStageWorker)
.to receive(:perform_async).with(project.id, {}, :protected_branches)
diff --git a/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb
index 932152c0764..199d1b9a3ca 100644
--- a/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb
@@ -7,23 +7,21 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssueEventsWorker do
let(:project) { create(:project) }
let!(:group) { create(:group, projects: [project]) }
- let(:feature_flag_state) { [group] }
- let(:single_endpoint_feature_flag_state) { [group] }
+ let(:settings) { ::Gitlab::GithubImport::Settings.new(project) }
+ let(:stage_enabled) { true }
+
+ before do
+ settings.write({ single_endpoint_issue_events_import: stage_enabled })
+ end
describe '#import' do
let(:importer) { instance_double('Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter') }
let(:client) { instance_double('Gitlab::GithubImport::Client') }
- before do
- stub_feature_flags(github_importer_single_endpoint_issue_events_import: single_endpoint_feature_flag_state)
- stub_feature_flags(github_importer_issue_events_import: feature_flag_state)
- end
-
- context 'when single endpoint feature flag enabled' do
- it 'imports all the issue events' do
+ context 'when stage is enabled' do
+ it 'imports issue events' do
waiter = Gitlab::JobWaiter.new(2, '123')
- expect(Gitlab::GithubImport::Importer::IssueEventsImporter).not_to receive(:new)
expect(Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter)
.to receive(:new)
.with(project, client)
@@ -39,35 +37,11 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssueEventsWorker do
end
end
- context 'when import issue events feature flag enabled' do
- let(:single_endpoint_feature_flag_state) { false }
-
- it 'imports the issue events partly' do
- waiter = Gitlab::JobWaiter.new(2, '123')
-
- expect(Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter).not_to receive(:new)
- expect(Gitlab::GithubImport::Importer::IssueEventsImporter)
- .to receive(:new)
- .with(project, client)
- .and_return(importer)
-
- expect(importer).to receive(:execute).and_return(waiter)
-
- expect(Gitlab::GithubImport::AdvanceStageWorker)
- .to receive(:perform_async)
- .with(project.id, { '123' => 2 }, :notes)
-
- worker.import(client, project)
- end
- end
-
- context 'when feature flags are disabled' do
- let(:feature_flag_state) { false }
- let(:single_endpoint_feature_flag_state) { false }
+ context 'when stage is disabled' do
+ let(:stage_enabled) { false }
it 'skips issue events import and calls next stage' do
expect(Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter).not_to receive(:new)
- expect(Gitlab::GithubImport::Importer::IssueEventsImporter).not_to receive(:new)
expect(Gitlab::GithubImport::AdvanceStageWorker).to receive(:perform_async).with(project.id, {}, :notes)
worker.import(client, project)
diff --git a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb
index a88256b3cae..beef0864715 100644
--- a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb
@@ -6,6 +6,13 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do
let(:project) { create(:project) }
let(:worker) { described_class.new }
+ let(:settings) { ::Gitlab::GithubImport::Settings.new(project) }
+ let(:single_endpoint_optional_stage) { true }
+
+ before do
+ settings.write({ single_endpoint_notes_import: single_endpoint_optional_stage })
+ end
+
describe '#import' do
it 'imports the issues and diff notes' do
client = double(:client)
@@ -33,37 +40,18 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do
end
describe '#importers' do
- context 'when project group is present' do
- let_it_be(:project) { create(:project) }
- let_it_be(:group) { create(:group, projects: [project]) }
-
- context 'when feature flag github_importer_single_endpoint_notes_import is enabled' do
- it 'includes single endpoint diff notes importer' do
- project = create(:project)
- group = create(:group, projects: [project])
-
- stub_feature_flags(github_importer_single_endpoint_notes_import: group)
-
- expect(worker.importers(project)).to contain_exactly(
- Gitlab::GithubImport::Importer::IssuesImporter,
- Gitlab::GithubImport::Importer::SingleEndpointDiffNotesImporter
- )
- end
- end
-
- context 'when feature flag github_importer_single_endpoint_notes_import is disabled' do
- it 'includes default diff notes importer' do
- stub_feature_flags(github_importer_single_endpoint_notes_import: false)
-
- expect(worker.importers(project)).to contain_exactly(
- Gitlab::GithubImport::Importer::IssuesImporter,
- Gitlab::GithubImport::Importer::DiffNotesImporter
- )
- end
+ context 'when optional stage single_endpoint_notes_import is enabled' do
+ it 'includes single endpoint diff notes importer' do
+ expect(worker.importers(project)).to contain_exactly(
+ Gitlab::GithubImport::Importer::IssuesImporter,
+ Gitlab::GithubImport::Importer::SingleEndpointDiffNotesImporter
+ )
end
end
- context 'when project group is missing' do
+ context 'when optional stage single_endpoint_notes_import is disabled' do
+ let(:single_endpoint_optional_stage) { false }
+
it 'includes default diff notes importer' do
expect(worker.importers(project)).to contain_exactly(
Gitlab::GithubImport::Importer::IssuesImporter,
diff --git a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb
index adf20d24a7e..dbcf2083ec1 100644
--- a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb
@@ -6,6 +6,13 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker do
let(:project) { create(:project) }
let(:worker) { described_class.new }
+ let(:settings) { ::Gitlab::GithubImport::Settings.new(project) }
+ let(:single_endpoint_optional_stage) { true }
+
+ before do
+ settings.write({ single_endpoint_notes_import: single_endpoint_optional_stage })
+ end
+
describe '#import' do
it 'imports all the notes' do
client = double(:client)
@@ -33,37 +40,19 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker do
end
describe '#importers' do
- context 'when project group is present' do
- let_it_be(:project) { create(:project) }
- let_it_be(:group) { create(:group, projects: [project]) }
-
- context 'when feature flag github_importer_single_endpoint_notes_import is enabled' do
- it 'includes single endpoint mr and issue notes importers' do
- project = create(:project)
- group = create(:group, projects: [project])
-
- stub_feature_flags(github_importer_single_endpoint_notes_import: group)
-
- expect(worker.importers(project)).to contain_exactly(
- Gitlab::GithubImport::Importer::SingleEndpointMergeRequestNotesImporter,
- Gitlab::GithubImport::Importer::SingleEndpointIssueNotesImporter
- )
- end
- end
-
- context 'when feature flag github_importer_single_endpoint_notes_import is disabled' do
- it 'includes default notes importer' do
- stub_feature_flags(github_importer_single_endpoint_notes_import: false)
-
- expect(worker.importers(project)).to contain_exactly(
- Gitlab::GithubImport::Importer::NotesImporter
- )
- end
+ context 'when settings single_endpoint_notes_import is enabled' do
+ it 'includes single endpoint mr and issue notes importers' do
+ expect(worker.importers(project)).to contain_exactly(
+ Gitlab::GithubImport::Importer::SingleEndpointMergeRequestNotesImporter,
+ Gitlab::GithubImport::Importer::SingleEndpointIssueNotesImporter
+ )
end
end
- context 'when project group is missing' do
- it 'includes default diff notes importer' do
+ context 'when settings single_endpoint_notes_import is disabled' do
+ let(:single_endpoint_optional_stage) { false }
+
+ it 'includes default notes importer' do
expect(worker.importers(project)).to contain_exactly(
Gitlab::GithubImport::Importer::NotesImporter
)
diff --git a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
index 582cb76a6cd..24fca3b7c73 100644
--- a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
@@ -19,18 +19,69 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
end
context 'when the import succeeds' do
- it 'schedules the importing of the base data' do
- client = double(:client)
+ context 'with issues' do
+ it 'schedules the importing of the base data' do
+ client = double(:client)
+ options = { state: 'all', sort: 'number', direction: 'desc', per_page: '1' }
- expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
- expect(instance).to receive(:execute).and_return(true)
+ expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
+ expect(instance).to receive(:execute).and_return(true)
+ end
+
+ expect(InternalId).to receive(:exists?).and_return(false)
+ expect(client).to receive(:each_object).with(
+ :issues, project.import_source, options
+ ).and_return([{ number: 5 }].each)
+
+ expect(Issue).to receive(:track_project_iid!).with(project, 5)
+
+ expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
+ .to receive(:perform_async)
+ .with(project.id)
+
+ worker.import(client, project)
end
+ end
- expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
- .to receive(:perform_async)
- .with(project.id)
+ context 'without issues' do
+ it 'schedules the importing of the base data' do
+ client = double(:client)
+ options = { state: 'all', sort: 'number', direction: 'desc', per_page: '1' }
+
+ expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
+ expect(instance).to receive(:execute).and_return(true)
+ end
+
+ expect(InternalId).to receive(:exists?).and_return(false)
+ expect(client).to receive(:each_object).with(:issues, project.import_source, options).and_return([nil].each)
+ expect(Issue).not_to receive(:track_project_iid!)
- worker.import(client, project)
+ expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
+ .to receive(:perform_async)
+ .with(project.id)
+
+ worker.import(client, project)
+ end
+ end
+
+ context 'when retrying' do
+ it 'does not allocate internal ids' do
+ client = double(:client)
+
+ expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
+ expect(instance).to receive(:execute).and_return(true)
+ end
+
+ expect(InternalId).to receive(:exists?).and_return(true)
+ expect(client).not_to receive(:each_object)
+ expect(Issue).not_to receive(:track_project_iid!)
+
+ expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
+ .to receive(:perform_async)
+ .with(project.id)
+
+ worker.import(client, project)
+ end
end
end
@@ -43,6 +94,10 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
expect(instance).to receive(:execute).and_raise(exception_class)
end
+ expect(InternalId).to receive(:exists?).and_return(false)
+ expect(client).to receive(:each_object).and_return([nil].each)
+ expect(Issue).not_to receive(:track_project_iid!)
+
expect(Gitlab::Import::ImportFailureService).to receive(:track)
.with(
project_id: project.id,