diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-05 10:52:53 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-05 10:52:53 +0200 |
commit | eedebb2bac097ddc4e6f1f5d958e9d54bb1540a2 (patch) | |
tree | 173746ed84fac129a71883b5f705160d0e3e4ef5 | |
parent | 7efef550da5e0901b7a4b6f94d49395fabbf2d38 (diff) | |
download | gitlab-ce-eedebb2bac097ddc4e6f1f5d958e9d54bb1540a2.tar.gz |
Improve specs and error messages in extendable config
-rw-r--r-- | lib/gitlab/ci/config/extendable/entry.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/extendable/entry_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/extendable_spec.rb | 31 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 2 |
4 files changed, 33 insertions, 6 deletions
diff --git a/lib/gitlab/ci/config/extendable/entry.rb b/lib/gitlab/ci/config/extendable/entry.rb index c6bfbad543e..7793db09d33 100644 --- a/lib/gitlab/ci/config/extendable/entry.rb +++ b/lib/gitlab/ci/config/extendable/entry.rb @@ -50,7 +50,7 @@ module Gitlab if unknown_extension? raise Entry::InvalidExtensionError, - "#{key}: unknown `extends` key" + "#{key}: unknown key in `extends`" end if invalid_base? @@ -60,7 +60,7 @@ module Gitlab if nesting_too_deep? raise Entry::NestingTooDeepError, - "#{key}: `extends` nesting too deep" + "#{key}: nesting too deep in `extends`" end if circular_dependency? diff --git a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb index e05bd22ebd0..0a148375d11 100644 --- a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb +++ b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb @@ -139,7 +139,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do it 'raises an error' do expect { subject.extend! } .to raise_error(described_class::InvalidExtensionError, - /unknown `extends` key/) + /unknown key/) end end diff --git a/spec/lib/gitlab/ci/config/extendable_spec.rb b/spec/lib/gitlab/ci/config/extendable_spec.rb index b985b95ada6..90213f6603d 100644 --- a/spec/lib/gitlab/ci/config/extendable_spec.rb +++ b/spec/lib/gitlab/ci/config/extendable_spec.rb @@ -80,9 +80,19 @@ describe Gitlab::Ci::Config::Extendable do only: { refs: %w[master] } }, + build: { + extends: 'something', + stage: 'build' + }, + + deploy: { + stage: 'deploy', + extends: '.first' + }, + something: { extends: '.first', - script: 'deploy', + script: 'exec', only: { variables: %w[$SOMETHING] } }, @@ -102,7 +112,24 @@ describe Gitlab::Ci::Config::Extendable do something: { extends: '.first', - script: 'deploy', + script: 'exec', + only: { + kubernetes: 'active', + variables: %w[$SOMETHING] + } + }, + + deploy: { + script: 'run', + stage: 'deploy', + only: { kubernetes: 'active' }, + extends: '.first' + }, + + build: { + extends: 'something', + script: 'exec', + stage: 'build', only: { kubernetes: 'active', variables: %w[$SOMETHING] diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index a75c8246758..fcbdf71a4e9 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1367,7 +1367,7 @@ module Gitlab expect { Gitlab::Ci::YamlProcessor.new(config) } .to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, - 'rspec: unknown `extends` key') + 'rspec: unknown key in `extends`') end end |