diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-28 18:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-28 18:08:36 +0300 |
commit | ee7db70e1185876e97eca97ce8efabfc64c360b9 (patch) | |
tree | 4c09297635be43c0189a2a85dd2a38d5f72bc523 /spec/lib/gitlab/config | |
parent | 3fa33c82f9c49f4b53ddcf017fe77f1bff48a460 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/config')
-rw-r--r-- | spec/lib/gitlab/config/loader/multi_doc_yaml_spec.rb | 24 |
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 |