summaryrefslogtreecommitdiff
path: root/spec/presenters/ci/build_runner_presenter_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/presenters/ci/build_runner_presenter_spec.rb
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/presenters/ci/build_runner_presenter_spec.rb')
-rw-r--r--spec/presenters/ci/build_runner_presenter_spec.rb60
1 files changed, 58 insertions, 2 deletions
diff --git a/spec/presenters/ci/build_runner_presenter_spec.rb b/spec/presenters/ci/build_runner_presenter_spec.rb
index d25102532a7..ace65307321 100644
--- a/spec/presenters/ci/build_runner_presenter_spec.rb
+++ b/spec/presenters/ci/build_runner_presenter_spec.rb
@@ -78,16 +78,72 @@ RSpec.describe Ci::BuildRunnerPresenter do
artifact_format: Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(file_type),
paths: [filename],
when: 'always'
- }
+ }.compact
end
it 'presents correct hash' do
- expect(presenter.artifacts.first).to include(report_expectation)
+ expect(presenter.artifacts).to contain_exactly(report_expectation)
end
end
end
end
+ context 'when a specific coverage_report type is given' do
+ let(:coverage_format) { :cobertura }
+ let(:filename) { 'cobertura-coverage.xml' }
+ let(:coverage_report) { { path: filename, coverage_format: coverage_format } }
+ let(:report) { { coverage_report: coverage_report } }
+ let(:build) { create(:ci_build, options: { artifacts: { reports: report } }) }
+
+ let(:expected_coverage_report) do
+ {
+ name: filename,
+ artifact_type: coverage_format,
+ artifact_format: Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(coverage_format),
+ paths: [filename],
+ when: 'always'
+ }
+ end
+
+ it 'presents the coverage report hash with the coverage format' do
+ expect(presenter.artifacts).to contain_exactly(expected_coverage_report)
+ end
+ end
+
+ context 'when a specific coverage_report type is given with another report type' do
+ let(:coverage_format) { :cobertura }
+ let(:coverage_filename) { 'cobertura-coverage.xml' }
+ let(:coverage_report) { { path: coverage_filename, coverage_format: coverage_format } }
+ let(:ds_filename) { 'gl-dependency-scanning-report.json' }
+
+ let(:report) { { coverage_report: coverage_report, dependency_scanning: [ds_filename] } }
+ let(:build) { create(:ci_build, options: { artifacts: { reports: report } }) }
+
+ let(:expected_coverage_report) do
+ {
+ name: coverage_filename,
+ artifact_type: coverage_format,
+ artifact_format: Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(coverage_format),
+ paths: [coverage_filename],
+ when: 'always'
+ }
+ end
+
+ let(:expected_ds_report) do
+ {
+ name: ds_filename,
+ artifact_type: :dependency_scanning,
+ artifact_format: Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(:dependency_scanning),
+ paths: [ds_filename],
+ when: 'always'
+ }
+ end
+
+ it 'presents both reports' do
+ expect(presenter.artifacts).to contain_exactly(expected_coverage_report, expected_ds_report)
+ end
+ end
+
context "when option has both archive and reports specification" do
let(:report) { { junit: ['junit.xml'] } }
let(:build) { create(:ci_build, options: { script: 'echo', artifacts: { **archive, reports: report } }) }