summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/config
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-20 11:43:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-20 11:43:17 +0000
commitdfc94207fec2d84314b1a5410cface22e8b369bd (patch)
treec54022f61ced104305889a64de080998a0dc773b /spec/lib/gitlab/config
parentb874efeff674f6bf0355d5d242ecf81c6f7155df (diff)
downloadgitlab-ce-dfc94207fec2d84314b1a5410cface22e8b369bd.tar.gz
Add latest changes from gitlab-org/gitlab@15-11-stable-eev15.11.0-rc42
Diffstat (limited to 'spec/lib/gitlab/config')
-rw-r--r--spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb b/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb
index f63aacecce6..438f3e5b17a 100644
--- a/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb
+++ b/spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb
@@ -3,7 +3,8 @@
require 'spec_helper'
RSpec.describe Gitlab::Config::Loader::MultiDocYaml, feature_category: :pipeline_composition do
- let(:loader) { described_class.new(yml, max_documents: 2) }
+ let(:loader) { described_class.new(yml, max_documents: 2, reject_empty: reject_empty) }
+ let(:reject_empty) { false }
describe '#load!' do
context 'when a simple single delimiter is being used' do
@@ -141,6 +142,27 @@ RSpec.describe Gitlab::Config::Loader::MultiDocYaml, feature_category: :pipeline
expect(loader.load!).to contain_exactly({ a: 1 }, { b: 2 })
end
end
+
+ context 'when the YAML contains empty documents' do
+ let(:yml) do
+ <<~YAML
+ a: 1
+ ---
+ YAML
+ end
+
+ it 'raises an error' do
+ expect { loader.load! }.to raise_error(::Gitlab::Config::Loader::Yaml::NotHashError)
+ end
+
+ context 'when reject_empty: true' do
+ let(:reject_empty) { true }
+
+ it 'loads only non empty documents' do
+ expect(loader.load!).to contain_exactly({ a: 1 })
+ end
+ end
+ end
end
describe '#load_raw!' do