summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/config/loader/yaml_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/config/loader/yaml_spec.rb')
-rw-r--r--spec/lib/gitlab/config/loader/yaml_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/lib/gitlab/config/loader/yaml_spec.rb b/spec/lib/gitlab/config/loader/yaml_spec.rb
index a52c1c362e1..623fe927233 100644
--- a/spec/lib/gitlab/config/loader/yaml_spec.rb
+++ b/spec/lib/gitlab/config/loader/yaml_spec.rb
@@ -5,6 +5,16 @@ require 'spec_helper'
describe Gitlab::Config::Loader::Yaml do
let(:loader) { described_class.new(yml) }
+ let(:yml) do
+ <<~YAML
+ image: 'ruby:2.7'
+ texts:
+ nested_key: 'value1'
+ more_text:
+ more_nested_key: 'value2'
+ YAML
+ end
+
context 'when yaml syntax is correct' do
let(:yml) { 'image: ruby:2.7' }
@@ -61,6 +71,15 @@ describe Gitlab::Config::Loader::Yaml do
expect(loader).not_to be_valid
end
end
+
+ describe '#load_raw!' do
+ it 'raises error' do
+ expect { loader.load_raw! }.to raise_error(
+ Gitlab::Config::Loader::FormatError,
+ 'Invalid configuration format'
+ )
+ end
+ end
end
# Prevent Billion Laughs attack: https://gitlab.com/gitlab-org/gitlab-foss/issues/56018
@@ -123,4 +142,32 @@ describe Gitlab::Config::Loader::Yaml do
end
end
end
+
+ describe '#load_raw!' do
+ it 'loads keys as strings' do
+ expect(loader.load_raw!).to eq(
+ 'image' => 'ruby:2.7',
+ 'texts' => {
+ 'nested_key' => 'value1',
+ 'more_text' => {
+ 'more_nested_key' => 'value2'
+ }
+ }
+ )
+ end
+ end
+
+ describe '#load!' do
+ it 'symbolizes keys' do
+ expect(loader.load!).to eq(
+ image: 'ruby:2.7',
+ texts: {
+ nested_key: 'value1',
+ more_text: {
+ more_nested_key: 'value2'
+ }
+ }
+ )
+ end
+ end
end