diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-17 15:13:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-17 15:13:40 +0300 |
commit | db30b31f056d0de120d9238a7786e19cafbce69f (patch) | |
tree | 9fc08f552865dc4e28eb9db475014f86cc061495 /spec/workers/projects/import_export/relation_export_worker_spec.rb | |
parent | aab0be458344b772293da292cba11648011c4c1e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/projects/import_export/relation_export_worker_spec.rb')
-rw-r--r-- | spec/workers/projects/import_export/relation_export_worker_spec.rb | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/spec/workers/projects/import_export/relation_export_worker_spec.rb b/spec/workers/projects/import_export/relation_export_worker_spec.rb index 7cd4e7afbe3..16ee73040b1 100644 --- a/spec/workers/projects/import_export/relation_export_worker_spec.rb +++ b/spec/workers/projects/import_export/relation_export_worker_spec.rb @@ -11,26 +11,61 @@ RSpec.describe Projects::ImportExport::RelationExportWorker, type: :worker, feat describe '#perform' do subject(:worker) { described_class.new } - context 'when relation export has initial state queued' do - let(:project_relation_export) { create(:project_relation_export) } + context 'when relation export has initial status `queued`' do + it 'exports the relation' do + expect_next_instance_of(Projects::ImportExport::RelationExportService) do |service| + expect(service).to receive(:execute) + end - it 'calls RelationExportService' do + worker.perform(project_relation_export.id) + end + end + + context 'when relation export has status `started`' do + let(:project_relation_export) { create(:project_relation_export, :started) } + + it 'retries the export of the relation' do expect_next_instance_of(Projects::ImportExport::RelationExportService) do |service| expect(service).to receive(:execute) end worker.perform(project_relation_export.id) + + expect(project_relation_export.reload.queued?).to eq(true) end end - context 'when relation export does not have queued state' do - let(:project_relation_export) { create(:project_relation_export, status_event: :start) } + context 'when relation export does not have status `queued` or `started`' do + let(:project_relation_export) { create(:project_relation_export, :finished) } - it 'does not call RelationExportService' do + it 'does not export the relation' do expect(Projects::ImportExport::RelationExportService).not_to receive(:new) worker.perform(project_relation_export.id) end end end + + describe '.sidekiq_retries_exhausted' do + let(:job) { { 'args' => [project_relation_export.id], 'error_message' => 'Error message' } } + + it 'sets relation export status to `failed`' do + described_class.sidekiq_retries_exhausted_block.call(job) + + expect(project_relation_export.reload.failed?).to eq(true) + end + + it 'logs the error message' do + expect_next_instance_of(Gitlab::Export::Logger) do |logger| + expect(logger).to receive(:error).with( + hash_including( + message: 'Project relation export failed', + export_error: 'Error message' + ) + ) + end + + described_class.sidekiq_retries_exhausted_block.call(job) + end + end end |