Add [] method for accessing ci entry dependencies
This commit is contained in:
parent
4f837f6690
commit
30f58cf392
|
@ -20,6 +20,10 @@ module Gitlab
|
|||
@validator.validate(:new)
|
||||
end
|
||||
|
||||
def [](key)
|
||||
@entries[key] || Node::Undefined.new
|
||||
end
|
||||
|
||||
def compose!(deps = nil)
|
||||
return unless valid?
|
||||
|
||||
|
|
|
@ -253,4 +253,27 @@ describe Gitlab::Ci::Config::Node::Global do
|
|||
expect(global.specified?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#[]' do
|
||||
before { global.compose! }
|
||||
|
||||
let(:hash) do
|
||||
{ cache: { key: 'a' }, rspec: { script: 'ls' } }
|
||||
end
|
||||
|
||||
context 'when node exists' do
|
||||
it 'returns correct entry' do
|
||||
expect(global[:cache])
|
||||
.to be_an_instance_of Gitlab::Ci::Config::Node::Cache
|
||||
expect(global[:jobs][:rspec][:script].value).to eq ['ls']
|
||||
end
|
||||
end
|
||||
|
||||
context 'when node does not exist' do
|
||||
it 'always return unspecified node' do
|
||||
expect(global[:some][:unknown][:node])
|
||||
.not_to be_specified
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue