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>2023-03-20 18:19:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-20 18:19:03 +0300
commit14bd84b61276ef29b97d23642d698de769bacfd2 (patch)
treef9eba90140c1bd874211dea17750a0d422c04080 /spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
parent891c388697b2db0d8ee0c8358a9bdbf6dc56d581 (diff)
Add latest changes from gitlab-org/gitlab@15-10-stable-eev15.10.0-rc42
Diffstat (limited to 'spec/workers/concerns/gitlab/github_import/object_importer_spec.rb')
-rw-r--r--spec/workers/concerns/gitlab/github_import/object_importer_spec.rb86
1 files changed, 75 insertions, 11 deletions
diff --git a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
index 02190201986..f72caf3a8c2 100644
--- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures do
+RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures, feature_category: :importers do
let(:worker) do
Class.new do
def self.name
@@ -196,6 +196,19 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures do
end
context 'when the record is invalid' do
+ let(:exception) { ActiveRecord::RecordInvalid.new }
+
+ before do
+ expect(importer_class)
+ .to receive(:new)
+ .with(instance_of(MockRepresantation), project, client)
+ .and_return(importer_instance)
+
+ expect(importer_instance)
+ .to receive(:execute)
+ .and_raise(exception)
+ end
+
it 'logs an error' do
expect(Gitlab::GithubImport::Logger)
.to receive(:info)
@@ -208,16 +221,6 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures do
}
)
- expect(importer_class)
- .to receive(:new)
- .with(instance_of(MockRepresantation), project, client)
- .and_return(importer_instance)
-
- exception = ActiveRecord::RecordInvalid.new
- expect(importer_instance)
- .to receive(:execute)
- .and_raise(exception)
-
expect(Gitlab::Import::ImportFailureService)
.to receive(:track)
.with(
@@ -230,6 +233,15 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures do
worker.import(project, client, { 'number' => 10, 'github_id' => 1 })
end
+
+ it 'updates external_identifiers of the correct failure' do
+ worker.import(project, client, { 'number' => 10, 'github_id' => 1 })
+
+ import_failures = project.import_failures
+
+ expect(import_failures.count).to eq(1)
+ expect(import_failures.first.external_identifiers).to eq(github_identifiers.with_indifferent_access)
+ end
end
end
@@ -240,4 +252,56 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures do
expect(worker).to be_increment_object_counter(issue)
end
end
+
+ describe '.sidekiq_retries_exhausted' do
+ let(:correlation_id) { 'abc' }
+ let(:job) do
+ {
+ 'args' => [project.id, { number: 123, state: 'open' }, '123abc'],
+ 'jid' => '123',
+ 'correlation_id' => correlation_id
+ }
+ end
+
+ subject(:sidekiq_retries_exhausted) { worker.class.sidekiq_retries_exhausted_block.call(job, StandardError.new) }
+
+ context 'when all arguments are given' do
+ it 'notifies the JobWaiter' do
+ expect(Gitlab::JobWaiter)
+ .to receive(:notify)
+ .with(
+ job['args'].last,
+ job['jid']
+ )
+
+ sidekiq_retries_exhausted
+ end
+ end
+
+ context 'when not all arguments are given' do
+ let(:job) do
+ {
+ 'args' => [project.id, { number: 123, state: 'open' }],
+ 'jid' => '123',
+ 'correlation_id' => correlation_id
+ }
+ end
+
+ it 'does not notify the JobWaiter' do
+ expect(Gitlab::JobWaiter).not_to receive(:notify)
+
+ sidekiq_retries_exhausted
+ end
+ end
+
+ it 'updates external_identifiers of the correct failure' do
+ failure_1, failure_2 = create_list(:import_failure, 2, project: project)
+ failure_2.update_column(:correlation_id_value, correlation_id)
+
+ sidekiq_retries_exhausted
+
+ expect(failure_1.reload.external_identifiers).to be_empty
+ expect(failure_2.reload.external_identifiers).to eq(github_identifiers.with_indifferent_access)
+ end
+ end
end