Commit b83fa58f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve extended CI/CD config error messages

parent d7133d94
......@@ -3,12 +3,12 @@ module Gitlab
class Config
class Extendable
class Entry
MAX_NESTING_LEVELS = 10
InvalidExtensionError = Class.new(Extendable::ExtensionError)
CircularDependencyError = Class.new(Extendable::ExtensionError)
NestingTooDeepError = Class.new(Extendable::ExtensionError)
MAX_NESTING_LEVELS = 10
attr_reader :key
def initialize(key, context, parent = nil)
......@@ -48,22 +48,22 @@ module Gitlab
if unknown_extension?
raise Entry::InvalidExtensionError,
"Unknown extends key in extended `#{key}`!"
"#{key}: unknown `extends` key"
end
if invalid_base?
raise Entry::InvalidExtensionError,
"Invalid base hash in extended `#{key}`!"
"#{key}: invalid base hash in `extends`"
end
if nesting_too_deep?
raise Entry::NestingTooDeepError,
"`extends` nesting too deep in `#{key}`!"
"#{key}: `extends` nesting too deep"
end
if circular_dependency?
raise Entry::CircularDependencyError,
"Circular dependency detected in extended `#{key}`!"
"#{key}: circular dependency detected in `extends`"
end
@context[key] = base_hash!.deep_merge(value)
......
......@@ -126,7 +126,8 @@ describe Gitlab::Ci::Config::Extendable::Entry do
it 'raises an error' do
expect { subject.extend! }
.to raise_error(StandardError, /Invalid base hash/)
.to raise_error(described_class::InvalidExtensionError,
/invalid base hash/)
end
end
......@@ -137,7 +138,8 @@ describe Gitlab::Ci::Config::Extendable::Entry do
it 'raises an error' do
expect { subject.extend! }
.to raise_error(StandardError, /Unknown extends key/)
.to raise_error(described_class::InvalidExtensionError,
/unknown `extends` key/)
end
end
......@@ -199,7 +201,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do
it 'raises an error' do
expect { subject.extend! }
.to raise_error(described_class::CircularDependencyError,
/Circular dependency detected/)
/circular dependency detected/)
end
end
......
......@@ -119,7 +119,7 @@ describe Gitlab::Ci::Config do
it 'raises an error' do
expect { config }.to raise_error(
described_class::ConfigError, /Circular dependency detected/
described_class::ConfigError, /circular dependency detected/
)
end
end
......
......@@ -1367,7 +1367,7 @@ module Gitlab
expect { Gitlab::Ci::YamlProcessor.new(config) }
.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
'Unknown extends key in extended `rspec`!')
'rspec: unknown `extends` key')
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