Commit 808fb254 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Raise exception when simplifiable ci entry incomplete

parent 6a5097fd
...@@ -6,6 +6,10 @@ module Gitlab ...@@ -6,6 +6,10 @@ module Gitlab
EntryStrategy = Struct.new(:name, :condition) EntryStrategy = Struct.new(:name, :condition)
def initialize(config, **metadata) def initialize(config, **metadata)
unless self.class.const_defined?(:UnknownStrategy)
raise ArgumentError, 'UndefinedStrategy not available!'
end
strategy = self.class.strategies.find do |variant| strategy = self.class.strategies.find do |variant|
variant.condition.call(config) variant.condition.call(config)
end end
......
...@@ -72,4 +72,17 @@ describe Gitlab::Ci::Config::Entry::Simplifiable do ...@@ -72,4 +72,17 @@ describe Gitlab::Ci::Config::Entry::Simplifiable do
end end
end end
end end
context 'when a unknown strategy class is not defined' do
let(:entry) do
Class.new(described_class) do
strategy :String, if: -> (*) { true }
end
end
it 'raises an error when being initialized' do
expect { entry.new('something') }
.to raise_error ArgumentError, /UndefinedStrategy not available!/
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