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/coverage_report_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/entry/reports/coverage_report_spec.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/reports/coverage_report_spec.rb b/spec/lib/gitlab/ci/config/entry/reports/coverage_report_spec.rb
new file mode 100644
index 00000000000..588f53150ff
--- /dev/null
+++ b/spec/lib/gitlab/ci/config/entry/reports/coverage_report_spec.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+
+RSpec.describe Gitlab::Ci::Config::Entry::Reports::CoverageReport do
+ let(:entry) { described_class.new(config) }
+
+ describe 'validations' do
+ context 'when it is valid' do
+ let(:config) { { coverage_format: 'cobertura', path: 'cobertura-coverage.xml' } }
+
+ it { expect(entry).to be_valid }
+
+ it { expect(entry.value).to eq(config) }
+ end
+
+ context 'with unsupported coverage format' do
+ let(:config) { { coverage_format: 'jacoco', path: 'jacoco.xml' } }
+
+ it { expect(entry).not_to be_valid }
+
+ it { expect(entry.errors).to include /format must be one of supported formats/ }
+ end
+
+ context 'without coverage format' do
+ let(:config) { { path: 'cobertura-coverage.xml' } }
+
+ it { expect(entry).not_to be_valid }
+
+ it { expect(entry.errors).to include /format can't be blank/ }
+ end
+
+ context 'without path' do
+ let(:config) { { coverage_format: 'cobertura' } }
+
+ it { expect(entry).not_to be_valid }
+
+ it { expect(entry.errors).to include /path can't be blank/ }
+ end
+
+ context 'with invalid path' do
+ let(:config) { { coverage_format: 'cobertura', path: 123 } }
+
+ it { expect(entry).not_to be_valid }
+
+ it { expect(entry.errors).to include /path should be a string/ }
+ end
+
+ context 'with unknown keys' do
+ let(:config) { { coverage_format: 'cobertura', path: 'cobertura-coverage.xml', foo: :bar } }
+
+ it { expect(entry).not_to be_valid }
+
+ it { expect(entry.errors).to include /contains unknown keys/ }
+ end
+ end
+end