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/include_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/entry/include_spec.rb72
1 files changed, 72 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/include_spec.rb b/spec/lib/gitlab/ci/config/entry/include_spec.rb
new file mode 100644
index 00000000000..bab11f26fa1
--- /dev/null
+++ b/spec/lib/gitlab/ci/config/entry/include_spec.rb
@@ -0,0 +1,72 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe ::Gitlab::Ci::Config::Entry::Include do
+ subject(:include_entry) { described_class.new(config) }
+
+ describe 'validations' do
+ before do
+ include_entry.compose!
+ end
+
+ context 'when value is a string' do
+ let(:config) { 'test.yml' }
+
+ it { is_expected.to be_valid }
+ end
+
+ context 'when value is hash' do
+ context 'when using not allowed keys' do
+ let(:config) do
+ { not_allowed: 'key' }
+ end
+
+ it { is_expected.not_to be_valid }
+ end
+
+ context 'when using "local"' do
+ let(:config) { { local: 'test.yml' } }
+
+ it { is_expected.to be_valid }
+ end
+
+ context 'when using "file"' do
+ let(:config) { { file: 'test.yml' } }
+
+ it { is_expected.to be_valid }
+ end
+
+ context 'when using "template"' do
+ let(:config) { { template: 'test.yml' } }
+
+ it { is_expected.to be_valid }
+ end
+
+ context 'when using "artifact"' do
+ context 'and specifying "job"' do
+ let(:config) { { artifact: 'test.yml', job: 'generator' } }
+
+ it { is_expected.to be_valid }
+ end
+
+ context 'without "job"' do
+ let(:config) { { artifact: 'test.yml' } }
+
+ it { is_expected.not_to be_valid }
+
+ it 'has specific error' do
+ expect(include_entry.errors)
+ .to include('include config must specify the job where to fetch the artifact from')
+ end
+ end
+ end
+ end
+
+ context 'when value is something else' do
+ let(:config) { 123 }
+
+ it { is_expected.not_to be_valid }
+ end
+ end
+end