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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-17 15:10:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-17 15:10:08 +0300
commit8060e5c60901ab0f6b890414dccbdf5d1b95c3ad (patch)
treefc217fe53f68a45ea225c0d1b966642852d96321 /spec/workers/gitlab/github_import
parentb9b58dba70466949d761132d2d96f0f24c0b469c (diff)
Add latest changes from gitlab-org/gitlab@master
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/stage/import_attachments_worker_spec.rb56
3 files changed, 102 insertions, 22 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/stage/import_attachments_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb
index 33e2443d106..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,8 +5,7 @@ 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_it_be(:project) { create(:project) }
let(:settings) { ::Gitlab::GithubImport::Settings.new(project) }
let(:stage_enabled) { true }
@@ -15,28 +14,42 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportAttachmentsWorker do
end
describe '#import' do
- let(:releases_importer) { instance_double('Gitlab::GithubImport::Importer::Attachments::ReleasesImporter') }
- let(:notes_importer) { instance_double('Gitlab::GithubImport::Importer::Attachments::NotesImporter') }
let(:client) { instance_double('Gitlab::GithubImport::Client') }
- let(:releases_waiter) { Gitlab::JobWaiter.new(2, '123') }
- let(:notes_waiter) { Gitlab::JobWaiter.new(3, '234') }
-
- it 'imports release attachments' do
- expect(Gitlab::GithubImport::Importer::Attachments::ReleasesImporter)
- .to receive(:new)
- .with(project, client)
- .and_return(releases_importer)
- expect(releases_importer).to receive(:execute).and_return(releases_waiter)
-
- expect(Gitlab::GithubImport::Importer::Attachments::NotesImporter)
- .to receive(:new)
- .with(project, client)
- .and_return(notes_importer)
- expect(notes_importer).to receive(:execute).and_return(notes_waiter)
+ 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 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, '234' => 3 }, :protected_branches)
+ .with(project.id, { '123' => 2, '234' => 3, '345' => 4, '456' => 5 }, :protected_branches)
worker.import(client, project)
end
@@ -45,8 +58,7 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportAttachmentsWorker do
let(:stage_enabled) { false }
it 'skips release attachments import and calls next stage' do
- expect(Gitlab::GithubImport::Importer::Attachments::ReleasesImporter).not_to receive(:new)
- expect(Gitlab::GithubImport::Importer::Attachments::NotesImporter).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)