diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb')
-rw-r--r-- | spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb b/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb index 98b01e2b303..403afde5da3 100644 --- a/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb +++ b/spec/services/ci/pipeline_artifacts/coverage_report_service_spec.rb @@ -4,17 +4,14 @@ require 'spec_helper' RSpec.describe ::Ci::PipelineArtifacts::CoverageReportService do describe '#execute' do - subject { described_class.new.execute(pipeline) } + let_it_be(:project) { create(:project, :repository) } - context 'when pipeline has coverage reports' do - let(:project) { create(:project, :repository) } - let(:pipeline) { create(:ci_pipeline, :with_coverage_reports, project: project) } + subject { described_class.new(pipeline).execute } + shared_examples 'creating a pipeline coverage report' do context 'when pipeline is finished' do it 'creates a pipeline artifact' do - subject - - expect(Ci::PipelineArtifact.count).to eq(1) + expect { subject }.to change { Ci::PipelineArtifact.count }.from(0).to(1) end it 'persists the default file name' do @@ -37,21 +34,32 @@ RSpec.describe ::Ci::PipelineArtifacts::CoverageReportService do end context 'when pipeline artifact has already been created' do - it 'do not raise an error and do not persist the same artifact twice' do - expect { 2.times { described_class.new.execute(pipeline) } }.not_to raise_error + it 'does not raise an error and does not persist the same artifact twice' do + expect { 2.times { described_class.new(pipeline).execute } }.not_to raise_error expect(Ci::PipelineArtifact.count).to eq(1) end end end + context 'when pipeline has coverage report' do + let!(:pipeline) { create(:ci_pipeline, :with_coverage_reports, project: project) } + + it_behaves_like 'creating a pipeline coverage report' + end + + context 'when pipeline has coverage report from child pipeline' do + let!(:pipeline) { create(:ci_pipeline, :success, project: project) } + let!(:child_pipeline) { create(:ci_pipeline, :with_coverage_reports, project: project, child_of: pipeline) } + + it_behaves_like 'creating a pipeline coverage report' + end + context 'when pipeline is running and coverage report does not exist' do let(:pipeline) { create(:ci_pipeline, :running) } it 'does not persist data' do - subject - - expect(Ci::PipelineArtifact.count).to eq(0) + expect { subject }.not_to change { Ci::PipelineArtifact.count } end end end |