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/stage')
-rw-r--r--spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb20
-rw-r--r--spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb20
-rw-r--r--spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_protected_branches_worker_spec.rb24
-rw-r--r--spec/workers/gitlab/github_import/stage/import_pull_requests_merged_by_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_pull_requests_review_requests_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_pull_requests_reviews_worker_spec.rb2
-rw-r--r--spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb24
-rw-r--r--spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb34
14 files changed, 28 insertions, 112 deletions
diff --git a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
index e517f30ee2c..6d8fa29bd27 100644
--- a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
@@ -6,6 +6,8 @@ RSpec.describe Gitlab::GithubImport::Stage::FinishImportWorker, feature_category
let(:project) { create(:project) }
let(:worker) { described_class.new }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#perform' do
it 'marks the import as finished and reports import statistics' do
expect(project).to receive(:after_import)
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 e385a5aaf3f..9a4b9106dae 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
@@ -13,6 +13,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportAttachmentsWorker, feature_cat
settings.write({ optional_stages: { attachments_import: stage_enabled } })
end
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
let(:client) { instance_double('Gitlab::GithubImport::Client') }
let(:importers) do
diff --git a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb
index 1ad027a007a..f3b706361e3 100644
--- a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb
@@ -10,6 +10,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportBaseDataWorker, feature_catego
let(:importer) { double(:importer) }
let(:client) { double(:client) }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports the base data of a project' do
described_class::IMPORTERS.each do |klass|
@@ -29,23 +31,5 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportBaseDataWorker, feature_catego
worker.import(client, project)
end
-
- it 'raises an error' do
- exception = StandardError.new('_some_error_')
-
- expect_next_instance_of(Gitlab::GithubImport::Importer::LabelsImporter) 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 { worker.import(client, project) }.to raise_error(StandardError)
- end
end
end
diff --git a/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb
index 808f6e827ed..fc38adb5447 100644
--- a/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb
@@ -12,6 +12,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportCollaboratorsWorker, feature_c
let(:importer) { instance_double(Gitlab::GithubImport::Importer::CollaboratorsImporter) }
let(:client) { instance_double(Gitlab::GithubImport::Client) }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
let(:push_rights_granted) { true }
@@ -68,23 +70,5 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportCollaboratorsWorker, feature_c
worker.import(client, project)
end
end
-
- it 'raises an error' do
- exception = StandardError.new('_some_error_')
-
- expect_next_instance_of(Gitlab::GithubImport::Importer::CollaboratorsImporter) 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 { worker.import(client, project) }.to raise_error(StandardError)
- end
end
end
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 7b0cf77bbbe..4b4d6a5b625 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
@@ -14,6 +14,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssueEventsWorker, feature_cat
settings.write({ optional_stages: { single_endpoint_issue_events_import: stage_enabled } })
end
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
let(:importer) { instance_double('Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter') }
let(:client) { instance_double('Gitlab::GithubImport::Client') }
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 188cf3530f7..7a5813122f4 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
@@ -13,6 +13,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker, feat
settings.write({ optional_stages: { single_endpoint_notes_import: single_endpoint_optional_stage } })
end
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports the issues and diff notes' do
client = double(:client)
diff --git a/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb
index 2449c0505f5..5d476543743 100644
--- a/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb
@@ -6,6 +6,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportLfsObjectsWorker, feature_cate
let(:project) { create(:project) }
let(:worker) { described_class.new }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports all the lfs objects' do
importer = double(:importer)
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 dcceeb1d6c2..9584708802a 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
@@ -13,6 +13,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker, feature_category:
settings.write({ optional_stages: { single_endpoint_notes_import: single_endpoint_optional_stage } })
end
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports all the notes' do
client = double(:client)
diff --git a/spec/workers/gitlab/github_import/stage/import_protected_branches_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_protected_branches_worker_spec.rb
index f848293a3b2..7ecce82dacb 100644
--- a/spec/workers/gitlab/github_import/stage/import_protected_branches_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_protected_branches_worker_spec.rb
@@ -10,6 +10,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportProtectedBranchesWorker, featu
let(:importer) { instance_double('Gitlab::GithubImport::Importer::ProtectedBranchImporter') }
let(:client) { instance_double('Gitlab::GithubImport::Client') }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports all the pull requests' do
waiter = Gitlab::JobWaiter.new(2, '123')
@@ -32,27 +34,5 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportProtectedBranchesWorker, featu
worker.import(client, project)
end
-
- context 'when an error raised' do
- let(:exception) { StandardError.new('_some_error_') }
-
- before do
- allow_next_instance_of(Gitlab::GithubImport::Importer::ProtectedBranchesImporter) do |importer|
- allow(importer).to receive(:execute).and_raise(exception)
- end
- end
-
- it 'raises an error' do
- expect(Gitlab::Import::ImportFailureService).to receive(:track)
- .with(
- project_id: project.id,
- exception: exception,
- error_source: described_class.name,
- metrics: true
- ).and_call_original
-
- expect { worker.import(client, project) }.to raise_error(StandardError)
- end
- end
end
end
diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_merged_by_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_merged_by_worker_spec.rb
index 0debabda0cc..5917b827d65 100644
--- a/spec/workers/gitlab/github_import/stage/import_pull_requests_merged_by_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_merged_by_worker_spec.rb
@@ -7,6 +7,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsMergedByWorker, fe
let(:import_state) { create(:import_state, project: project) }
let(:worker) { described_class.new }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports all the pull requests' do
importer = double(:importer)
diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_review_requests_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_review_requests_worker_spec.rb
index 41c0b29df7c..b473de73086 100644
--- a/spec/workers/gitlab/github_import/stage/import_pull_requests_review_requests_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_review_requests_worker_spec.rb
@@ -11,6 +11,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsReviewRequestsWork
let(:importer) { instance_double(Gitlab::GithubImport::Importer::PullRequests::ReviewRequestsImporter) }
let(:waiter) { Gitlab::JobWaiter.new(2, '123') }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports all PR review requests' do
expect(Gitlab::GithubImport::Importer::PullRequests::ReviewRequestsImporter)
diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_reviews_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_reviews_worker_spec.rb
index b1141c7f324..34d3ce9fe95 100644
--- a/spec/workers/gitlab/github_import/stage/import_pull_requests_reviews_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_reviews_worker_spec.rb
@@ -8,6 +8,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsReviewsWorker, fea
let(:worker) { described_class.new }
let(:client) { double(:client) }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
it 'imports all the pull request reviews' do
importer = double(:importer)
diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb
index 9b2cfead684..f9b4a8a99f0 100644
--- a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb
@@ -11,6 +11,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker, feature_ca
let(:importer) { double(:importer) }
let(:client) { double(:client) }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
context 'with pull requests' do
it 'imports all the pull requests and allocates internal iids' do
@@ -101,26 +103,4 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker, feature_ca
end
end
end
-
- it 'raises an error' do
- exception = StandardError.new('_some_error_')
-
- expect(client).to receive(:each_object).with(
- :pulls, project.import_source, options
- ).and_return([{ number: 4 }].each)
-
- expect_next_instance_of(Gitlab::GithubImport::Importer::PullRequestsImporter) 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 { worker.import(client, project) }.to raise_error(StandardError)
- end
end
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 94d8155d371..f4a306eeb0c 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
@@ -7,6 +7,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker, feature_cate
let(:worker) { described_class.new }
+ it_behaves_like Gitlab::GithubImport::StageMethods
+
describe '#import' do
before do
expect(Gitlab::GithubImport::RefreshImportJidWorker)
@@ -84,37 +86,5 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker, feature_cate
end
end
end
-
- context 'when the import fails' do
- it 'does not schedule the importing of the base data' do
- client = double(:client)
- exception_class = Gitlab::Git::Repository::NoRepository
-
- expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
- 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_namespace_iid!)
-
- expect(Gitlab::Import::ImportFailureService).to receive(:track)
- .with(
- project_id: project.id,
- exception: exception_class,
- error_source: described_class.name,
- fail_import: true,
- metrics: true
- ).and_call_original
-
- expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
- .not_to receive(:perform_async)
-
- expect(worker.abort_on_failure).to eq(true)
-
- expect { worker.import(client, project) }
- .to raise_error(exception_class)
- end
- end
end
end