diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 18:09:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 18:09:56 +0300 |
commit | c08d9c22569d1c9e7c7737e183969593394133d9 (patch) | |
tree | 8ce1722f852f8921656080e04f6c9e16fa71ddb5 /spec/lib/gitlab/ci | |
parent | 546ddc3f6ac96fdf09934390a938bb391d07dc94 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 62adba4319e..0b34e887716 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1647,6 +1647,48 @@ module Gitlab it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /is not defined in prior stages/) } end + + context 'when trigger job includes artifact generated by a dependency' do + context 'when dependency is defined in previous stages' do + let(:config) do + { + build1: { stage: 'build', script: 'test' }, + test1: { stage: 'test', trigger: { + include: [{ job: 'build1', artifact: 'generated.yml' }] + } } + } + end + + it { expect { subject }.not_to raise_error } + end + + context 'when dependency is defined in later stages' do + let(:config) do + { + build1: { stage: 'build', script: 'test' }, + test1: { stage: 'test', trigger: { + include: [{ job: 'deploy1', artifact: 'generated.yml' }] + } }, + deploy1: { stage: 'deploy', script: 'test' } + } + end + + it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /is not defined in prior stages/) } + end + + context 'when dependency is not defined' do + let(:config) do + { + build1: { stage: 'build', script: 'test' }, + test1: { stage: 'test', trigger: { + include: [{ job: 'non-existent', artifact: 'generated.yml' }] + } } + } + end + + it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /undefined dependency: non-existent/) } + end + end end describe "Job Needs" do @@ -2052,6 +2094,34 @@ module Gitlab end end + describe 'with trigger:include' 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 artifact is specified without job' do + let(:config) do + YAML.dump({ + build1: { stage: 'build', script: 'test' }, + test1: { stage: 'test', trigger: { + include: [{ artifact: 'generated.yml' }] + } } + }) + end + + it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /must specify the job where to fetch the artifact from/) } + end + end + describe "Error handling" do it "fails to parse YAML" do expect do |