diff options
Diffstat (limited to 'spec/lib/gitlab/ci/yaml_processor_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index d596494a987..fb6395e888a 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1361,7 +1361,8 @@ module Gitlab paths: ["logs/", "binaries/"], untracked: true, key: 'key', - policy: 'pull-push' + policy: 'pull-push', + when: 'on_success' ) end @@ -1383,7 +1384,8 @@ module Gitlab paths: ["logs/", "binaries/"], untracked: true, key: { files: ['file'] }, - policy: 'pull-push' + policy: 'pull-push', + when: 'on_success' ) end @@ -1402,7 +1404,8 @@ module Gitlab paths: ['logs/', 'binaries/'], untracked: true, key: 'key', - policy: 'pull-push' + policy: 'pull-push', + when: 'on_success' ) end @@ -1425,7 +1428,8 @@ module Gitlab paths: ['logs/', 'binaries/'], untracked: true, key: { files: ['file'] }, - policy: 'pull-push' + policy: 'pull-push', + when: 'on_success' ) end @@ -1448,7 +1452,8 @@ module Gitlab paths: ['logs/', 'binaries/'], untracked: true, key: { files: ['file'], prefix: 'prefix' }, - policy: 'pull-push' + policy: 'pull-push', + when: 'on_success' ) end @@ -1468,7 +1473,8 @@ module Gitlab paths: ["test/"], untracked: false, key: 'local', - policy: 'pull-push' + policy: 'pull-push', + when: 'on_success' ) end end @@ -2240,47 +2246,49 @@ module Gitlab end describe 'with parent-child pipeline' do + let(:config) do + YAML.dump({ + build1: { stage: 'build', script: 'test' }, + test1: { + stage: 'test', + trigger: { + include: includes + } + } + }) + end + 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 + let(:includes) { [{ artifact: 'generated.yml', job: 'build1' }] } it { is_expected.to be_valid } 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 + context 'when job is not specified while artifact is' do + let(:includes) { [{ artifact: 'generated.yml' }] } it_behaves_like 'returns errors', /include config must specify the job where to fetch the artifact from/ 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' - } - } - }) + context 'when project and file are specified' do + let(:includes) do + [{ file: 'generated.yml', project: 'my-namespace/my-project' }] end it { is_expected.to be_valid } end + + context 'when file is not specified while project is' do + let(:includes) { [{ project: 'something' }] } + + it_behaves_like 'returns errors', /include config must specify the file where to fetch the config from/ + end + + context 'when include is a string' do + let(:includes) { 'generated.yml' } + + it { is_expected.to be_valid } + end end describe "Error handling" do @@ -2457,13 +2465,13 @@ module Gitlab context 'returns errors if variables is not a map' do let(:config) { YAML.dump({ variables: "test", rspec: { script: "test" } }) } - it_behaves_like 'returns errors', 'variables config should be a hash of key value pairs' + it_behaves_like 'returns errors', 'variables config should be a hash of key value pairs, value can be a hash' end context 'returns errors if variables is not a map of key-value strings' do let(:config) { YAML.dump({ variables: { test: false }, rspec: { script: "test" } }) } - it_behaves_like 'returns errors', 'variables config should be a hash of key value pairs' + it_behaves_like 'returns errors', 'variables config should be a hash of key value pairs, value can be a hash' end context 'returns errors if job when is not on_success, on_failure or always' do |