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-06-23 21:09:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-23 21:09:26 +0300
commit35272ed523e03fd0f2a77e6951eb4017cdb224ff (patch)
tree0491e10e68a7932168c9ddadfb0de26780de4ad3 /spec/workers/ci
parentcd81aadde2782c9fbb0ad69d5471bad792345120 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/ci')
-rw-r--r--spec/workers/ci/pipeline_artifacts/coverage_report_worker_spec.rb57
1 files changed, 50 insertions, 7 deletions
diff --git a/spec/workers/ci/pipeline_artifacts/coverage_report_worker_spec.rb b/spec/workers/ci/pipeline_artifacts/coverage_report_worker_spec.rb
index 000eda055af..f51e66aa948 100644
--- a/spec/workers/ci/pipeline_artifacts/coverage_report_worker_spec.rb
+++ b/spec/workers/ci/pipeline_artifacts/coverage_report_worker_spec.rb
@@ -2,28 +2,71 @@
require 'spec_helper'
-RSpec.describe ::Ci::PipelineArtifacts::CoverageReportWorker do
+RSpec.describe Ci::PipelineArtifacts::CoverageReportWorker do
describe '#perform' do
+ let(:pipeline_id) { pipeline.id }
+
subject { described_class.new.perform(pipeline_id) }
context 'when pipeline exists' do
- let(:pipeline) { create(:ci_pipeline) }
- let(:pipeline_id) { pipeline.id }
+ let(:pipeline) { create(:ci_pipeline, :success) }
- it 'calls pipeline report result service' do
- expect_next_instance_of(::Ci::PipelineArtifacts::CoverageReportService) do |create_artifact_service|
- expect(create_artifact_service).to receive(:execute)
+ it 'calls the pipeline coverage report service' do
+ expect_next_instance_of(::Ci::PipelineArtifacts::CoverageReportService, pipeline) do |service|
+ expect(service).to receive(:execute)
end
subject
end
end
+ context 'when the pipeline is part of a hierarchy' do
+ let_it_be(:root_ancestor_pipeline) { create(:ci_pipeline, :success) }
+ let_it_be(:pipeline) { create(:ci_pipeline, :success, child_of: root_ancestor_pipeline) }
+ let_it_be(:another_child_pipeline) { create(:ci_pipeline, :success, child_of: root_ancestor_pipeline) }
+
+ context 'when all pipelines is complete' do
+ it 'calls the pipeline coverage report service on the root ancestor pipeline' do
+ expect_next_instance_of(::Ci::PipelineArtifacts::CoverageReportService, root_ancestor_pipeline) do |service|
+ expect(service).to receive(:execute)
+ end
+
+ subject
+ end
+ end
+
+ context 'when the pipeline hierarchy has incomplete pipeline' do
+ before do
+ another_child_pipeline.update!(status: :running)
+ end
+
+ it 'does not call pipeline coverage report service' do
+ expect(Ci::PipelineArtifacts::CoverageReportService).not_to receive(:new)
+
+ subject
+ end
+ end
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(ci_child_pipeline_coverage_reports: false)
+ end
+
+ it 'calls the pipeline coverage report service on the pipeline' do
+ expect_next_instance_of(::Ci::PipelineArtifacts::CoverageReportService, pipeline) do |service|
+ expect(service).to receive(:execute)
+ end
+
+ subject
+ end
+ end
+ end
+
context 'when pipeline does not exist' do
let(:pipeline_id) { non_existing_record_id }
it 'does not call pipeline create artifact service' do
- expect(Ci::PipelineArtifacts::CoverageReportService).not_to receive(:execute)
+ expect(Ci::PipelineArtifacts::CoverageReportService).not_to receive(:new)
subject
end