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:
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/reports_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/entry/reports_spec.rb47
1 files changed, 41 insertions, 6 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
index 12b8960eb32..061d8f34c8d 100644
--- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
@@ -6,12 +6,8 @@ RSpec.describe Gitlab::Ci::Config::Entry::Reports do
let(:entry) { described_class.new(config) }
describe 'validates ALLOWED_KEYS' do
- let(:artifact_file_types) { Ci::JobArtifact.file_types }
-
- described_class::ALLOWED_KEYS.each do |keyword, _|
- it "expects #{keyword} to be an artifact file_type" do
- expect(artifact_file_types).to include(keyword)
- end
+ it "expects ALLOWED_KEYS to be an artifact file_type or coverage_report" do
+ expect(Ci::JobArtifact.file_types.keys.map(&:to_sym) + [:coverage_report]).to include(*described_class::ALLOWED_KEYS)
end
end
@@ -68,6 +64,45 @@ RSpec.describe Gitlab::Ci::Config::Entry::Reports do
it_behaves_like 'a valid entry', params[:keyword], params[:file]
end
end
+
+ context 'when coverage_report is specified' do
+ let(:coverage_format) { :cobertura }
+ let(:filename) { 'cobertura-coverage.xml' }
+ let(:coverage_report) { { path: filename, coverage_format: coverage_format } }
+ let(:config) { { coverage_report: coverage_report } }
+
+ it 'is valid' do
+ expect(entry).to be_valid
+ end
+
+ it 'returns artifacts configuration' do
+ expect(entry.value).to eq(config)
+ end
+
+ context 'and another report is specified' do
+ let(:config) { { coverage_report: coverage_report, dast: 'gl-dast-report.json' } }
+
+ it 'is valid' do
+ expect(entry).to be_valid
+ end
+
+ it 'returns artifacts configuration' do
+ expect(entry.value).to eq({ coverage_report: coverage_report, dast: ['gl-dast-report.json'] })
+ end
+ end
+
+ context 'and a direct coverage report format is specified' do
+ let(:config) { { coverage_report: coverage_report, cobertura: 'cobertura-coverage.xml' } }
+
+ it 'is not valid' do
+ expect(entry).not_to be_valid
+ end
+
+ it 'reports error' do
+ expect(entry.errors).to include /please use only one the following keys: coverage_report, cobertura/
+ end
+ end
+ end
end
context 'when entry value is not correct' do