diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-12 18:08:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-12 18:08:32 +0300 |
commit | b17f0b91a66f2101a54dd1efed0c4973f04b1daf (patch) | |
tree | 55d2a3dc5581b90bd1304c5d53d4d5b5da0076c9 /spec/lib/gitlab/config | |
parent | b47e7cd6b2049c1fb87e7c4ffd1de898cda52364 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/config')
-rw-r--r-- | spec/lib/gitlab/config/entry/composable_array_spec.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/lib/gitlab/config/entry/composable_array_spec.rb b/spec/lib/gitlab/config/entry/composable_array_spec.rb new file mode 100644 index 00000000000..77766cb3b0a --- /dev/null +++ b/spec/lib/gitlab/config/entry/composable_array_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Config::Entry::ComposableArray, :aggregate_failures do + let(:valid_config) do + [ + { + DATABASE_SECRET: 'passw0rd' + }, + { + API_TOKEN: 'passw0rd2' + } + ] + end + + let(:config) { valid_config } + let(:entry) { described_class.new(config) } + + before do + allow(entry).to receive(:composable_class).and_return(Gitlab::Config::Entry::Node) + end + + describe '#valid?' do + it 'is valid' do + expect(entry).to be_valid + end + + context 'is invalid' do + let(:config) { { hello: :world } } + + it { expect(entry).not_to be_valid } + end + end + + describe '#compose!' do + before do + entry.compose! + end + + it 'composes child entry with configured value' do + expect(entry.value).to eq(config) + end + + it 'composes child entries with configured values' do + expect(entry[0]).to be_a(Gitlab::Config::Entry::Node) + expect(entry[0].description).to eq('node definition') + expect(entry[0].key).to eq('node') + expect(entry[0].metadata).to eq({}) + expect(entry[0].parent.class).to eq(Gitlab::Config::Entry::ComposableArray) + expect(entry[0].value).to eq(DATABASE_SECRET: 'passw0rd') + expect(entry[1]).to be_a(Gitlab::Config::Entry::Node) + expect(entry[1].description).to eq('node definition') + expect(entry[1].key).to eq('node') + expect(entry[1].metadata).to eq({}) + expect(entry[1].parent.class).to eq(Gitlab::Config::Entry::ComposableArray) + expect(entry[1].value).to eq(API_TOKEN: 'passw0rd2') + end + + describe '#descendants' do + it 'creates descendant nodes' do + expect(entry.descendants.first).to be_a(Gitlab::Config::Entry::Node) + expect(entry.descendants.first.value).to eq(DATABASE_SECRET: 'passw0rd') + expect(entry.descendants.second).to be_a(Gitlab::Config::Entry::Node) + expect(entry.descendants.second.value).to eq(API_TOKEN: 'passw0rd2') + end + end + end +end |