Commit eedebb2b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve specs and error messages in extendable config

parent 7efef550
...@@ -50,7 +50,7 @@ module Gitlab ...@@ -50,7 +50,7 @@ module Gitlab
if unknown_extension? if unknown_extension?
raise Entry::InvalidExtensionError, raise Entry::InvalidExtensionError,
"#{key}: unknown `extends` key" "#{key}: unknown key in `extends`"
end end
if invalid_base? if invalid_base?
...@@ -60,7 +60,7 @@ module Gitlab ...@@ -60,7 +60,7 @@ module Gitlab
if nesting_too_deep? if nesting_too_deep?
raise Entry::NestingTooDeepError, raise Entry::NestingTooDeepError,
"#{key}: `extends` nesting too deep" "#{key}: nesting too deep in `extends`"
end end
if circular_dependency? if circular_dependency?
......
...@@ -139,7 +139,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do ...@@ -139,7 +139,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do
it 'raises an error' do it 'raises an error' do
expect { subject.extend! } expect { subject.extend! }
.to raise_error(described_class::InvalidExtensionError, .to raise_error(described_class::InvalidExtensionError,
/unknown `extends` key/) /unknown key/)
end end
end end
......
...@@ -80,9 +80,19 @@ describe Gitlab::Ci::Config::Extendable do ...@@ -80,9 +80,19 @@ describe Gitlab::Ci::Config::Extendable do
only: { refs: %w[master] } only: { refs: %w[master] }
}, },
build: {
extends: 'something',
stage: 'build'
},
deploy: {
stage: 'deploy',
extends: '.first'
},
something: { something: {
extends: '.first', extends: '.first',
script: 'deploy', script: 'exec',
only: { variables: %w[$SOMETHING] } only: { variables: %w[$SOMETHING] }
}, },
...@@ -102,7 +112,24 @@ describe Gitlab::Ci::Config::Extendable do ...@@ -102,7 +112,24 @@ describe Gitlab::Ci::Config::Extendable do
something: { something: {
extends: '.first', 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: { only: {
kubernetes: 'active', kubernetes: 'active',
variables: %w[$SOMETHING] variables: %w[$SOMETHING]
......
...@@ -1367,7 +1367,7 @@ module Gitlab ...@@ -1367,7 +1367,7 @@ module Gitlab
expect { Gitlab::Ci::YamlProcessor.new(config) } expect { Gitlab::Ci::YamlProcessor.new(config) }
.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, .to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
'rspec: unknown `extends` key') 'rspec: unknown key in `extends`')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment