Commit ce42a90f authored by King Chung Huang's avatar King Chung Huang Committed by Dylan Griffith

Add a spec for merging overlapping dicts

When both external files and gitlab_ci.yml define a dictionary of
variables where some variable keys overlap, later declarations should
take precedence.
parent efa481b8
...@@ -137,5 +137,32 @@ describe EE::Gitlab::Ci::Config do ...@@ -137,5 +137,32 @@ describe EE::Gitlab::Ci::Config do
expect(config.to_hash).to eq({ A: 'alpha', B: 'beta', C: 'gamma', D: 'delta' }) expect(config.to_hash).to eq({ A: 'alpha', B: 'beta', C: 'gamma', D: 'delta' })
end end
end end
context "when both external files and gitlab_ci.yml define a dictionary of overlapping variables" do
let(:remote_file_content) do
<<~HEREDOC
variables:
A: 'alpha'
B: 'beta'
C: 'omnicron'
HEREDOC
end
let(:gitlab_ci_yml) do
<<~HEREDOC
include:
- #{remote_location}
variables:
C: 'gamma'
D: 'delta'
HEREDOC
end
it 'later declarations should take precedence' do
WebMock.stub_request(:get, remote_location).to_return(body: remote_file_content)
expect(config.to_hash).to eq({ A: 'alpha', B: 'beta', C: 'gamma', D: 'delta' })
end
end
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