diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 15:09:29 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 15:09:29 +0000 |
commit | 209bd8cf1f542f6ba2a069b368a9187faa871e96 (patch) | |
tree | 6b77dc8183135b8316cc70c8dbc9c4e7c18cf05a /spec/lib/gitlab/ci | |
parent | a9ced7da447785c57477b3d8dbccc73a78cface1 (diff) | |
download | gitlab-ce-209bd8cf1f542f6ba2a069b368a9187faa871e96.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/include_spec.rb | 72 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 48 |
2 files changed, 120 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 diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 62adba4319e..70c3c5ab339 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -2052,6 +2052,54 @@ module Gitlab end end + describe 'with parent-child pipeline' do + context 'when artifact and job are specified' do + let(:config) do + YAML.dump({ + build1: { stage: 'build', script: 'test' }, + test1: { stage: 'test', trigger: { + include: [{ artifact: 'generated.yml', job: 'build1' }] + } } + }) + end + + it { expect { subject }.not_to raise_error } + end + + context 'when job is not specified specified while artifact is' do + let(:config) do + YAML.dump({ + build1: { stage: 'build', script: 'test' }, + test1: { stage: 'test', trigger: { + include: [{ artifact: 'generated.yml' }] + } } + }) + end + + it do + expect { subject }.to raise_error( + described_class::ValidationError, + /include config must specify the job where to fetch the artifact from/) + end + end + + context 'when include is a string' do + let(:config) do + YAML.dump({ + build1: { stage: 'build', script: 'test' }, + test1: { + stage: 'test', + trigger: { + include: 'generated.yml' + } + } + }) + end + + it { expect { subject }.not_to raise_error } + end + end + describe "Error handling" do it "fails to parse YAML" do expect do |