diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-28 13:25:25 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-28 13:25:25 +0100 |
commit | 1d27bf923207c1b755b074e2dbff1a36369837de (patch) | |
tree | bde97d4ab78b8a92bff3cc2f0d7cf3c8e2d4ef78 | |
parent | 51727377a243238984425d7e3c8ca48658613733 (diff) | |
download | gitlab-ce-1d27bf923207c1b755b074e2dbff1a36369837de.tar.gz |
Add YAML integration tests for pipeline expressions
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index b9fccf47e79..34997d0991b 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -213,6 +213,22 @@ module Gitlab end end end + + context 'when variables policy is specified' do + let(:config) do + YAML.dump(unit: { script: 'minitest', only: { variables: ['$CI_PIPELINE_SOURCE'] } }, + feature: { script: 'spinach', only: { variables: ['$UNDEFINED'] } }) + end + + let(:pipeline) { create(:ci_empty_pipeline) } + + it 'returns stage seeds only when variables expression is truthy' do + seeds = subject.stage_seeds(pipeline) + + expect(seeds.size).to eq 1 + expect(seeds.first.builds.dig(0, :name)).to eq 'unit' + end + end end describe "#pipeline_stage_builds" do @@ -1677,6 +1693,14 @@ module Gitlab Gitlab::Ci::YamlProcessor.new(config) end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec dependencies should be an array of strings") end + + it 'returns errors if pipeline variables expression is invalid' do + config = YAML.dump({ rspec: { script: 'test', only: { variables: ['== null'] } } }) + + expect { Gitlab::Ci::YamlProcessor.new(config) } + .to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, + 'jobs:rspec:only variables invalid expression syntax: equals null') + end end describe "Validate configuration templates" do |