Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-19 01:14:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-19 01:14:29 +0300
commit9eeb914c7a90424e68d5737f34d9c5aee13508c6 (patch)
treef49f7a47517c598ab5cebe7c770789d83d5e2891 /spec/lib/gitlab/ci/variables/helpers_spec.rb
parent6026722aa6e33b2b7bebabac8f611507f535ca12 (diff)
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc44
Diffstat (limited to 'spec/lib/gitlab/ci/variables/helpers_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/variables/helpers_spec.rb123
1 files changed, 62 insertions, 61 deletions
diff --git a/spec/lib/gitlab/ci/variables/helpers_spec.rb b/spec/lib/gitlab/ci/variables/helpers_spec.rb
index 2a1cdaeb3a7..fc1055751bd 100644
--- a/spec/lib/gitlab/ci/variables/helpers_spec.rb
+++ b/spec/lib/gitlab/ci/variables/helpers_spec.rb
@@ -15,27 +15,21 @@ RSpec.describe Gitlab::Ci::Variables::Helpers do
end
let(:result) do
- [{ key: 'key1', value: 'value1' },
- { key: 'key2', value: 'value22' },
- { key: 'key3', value: 'value3' }]
+ [{ key: 'key1', value: 'value1', public: true },
+ { key: 'key2', value: 'value22', public: true },
+ { key: 'key3', value: 'value3', public: true }]
end
subject { described_class.merge_variables(current_variables, new_variables) }
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq(result) }
context 'when new variables is a hash' do
let(:new_variables) do
{ 'key2' => 'value22', 'key3' => 'value3' }
end
- let(:result) do
- [{ key: 'key1', value: 'value1' },
- { key: 'key2', value: 'value22' },
- { key: 'key3', value: 'value3' }]
- end
-
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq(result) }
end
context 'when new variables is a hash with symbol keys' do
@@ -43,72 +37,79 @@ RSpec.describe Gitlab::Ci::Variables::Helpers do
{ key2: 'value22', key3: 'value3' }
end
- let(:result) do
- [{ key: 'key1', value: 'value1' },
- { key: 'key2', value: 'value22' },
- { key: 'key3', value: 'value3' }]
- end
-
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq(result) }
end
context 'when new variables is nil' do
let(:new_variables) {}
let(:result) do
- [{ key: 'key1', value: 'value1' },
- { key: 'key2', value: 'value2' }]
+ [{ key: 'key1', value: 'value1', public: true },
+ { key: 'key2', value: 'value2', public: true }]
end
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq(result) }
end
end
- describe '.transform_to_array' do
- subject { described_class.transform_to_array(variables) }
+ describe '.transform_to_yaml_variables' do
+ let(:variables) do
+ { 'key1' => 'value1', 'key2' => 'value2' }
+ end
- context 'when values are strings' do
- let(:variables) do
- { 'key1' => 'value1', 'key2' => 'value2' }
- end
+ let(:result) do
+ [{ key: 'key1', value: 'value1', public: true },
+ { key: 'key2', value: 'value2', public: true }]
+ end
- let(:result) do
- [{ key: 'key1', value: 'value1' },
- { key: 'key2', value: 'value2' }]
- end
+ subject { described_class.transform_to_yaml_variables(variables) }
+
+ it { is_expected.to eq(result) }
+
+ context 'when variables is nil' do
+ let(:variables) {}
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq([]) }
+ end
+ end
+
+ describe '.transform_from_yaml_variables' do
+ let(:variables) do
+ [{ key: 'key1', value: 'value1', public: true },
+ { key: 'key2', value: 'value2', public: true }]
end
+ let(:result) do
+ { 'key1' => 'value1', 'key2' => 'value2' }
+ end
+
+ subject { described_class.transform_from_yaml_variables(variables) }
+
+ it { is_expected.to eq(result) }
+
context 'when variables is nil' do
let(:variables) {}
- it { is_expected.to match_array([]) }
+ it { is_expected.to eq({}) }
end
- context 'when values are hashes' do
+ context 'when variables is a hash' do
let(:variables) do
- { 'key1' => { value: 'value1', description: 'var 1' }, 'key2' => { value: 'value2' } }
- end
-
- let(:result) do
- [{ key: 'key1', value: 'value1', description: 'var 1' },
- { key: 'key2', value: 'value2' }]
+ { key1: 'value1', 'key2' => 'value2' }
end
- it { is_expected.to match_array(result) }
-
- context 'when a value data has `key` as a key' do
- let(:variables) do
- { 'key1' => { value: 'value1', key: 'new_key1' }, 'key2' => { value: 'value2' } }
- end
+ it { is_expected.to eq(result) }
+ end
- let(:result) do
- [{ key: 'key1', value: 'value1' },
- { key: 'key2', value: 'value2' }]
- end
+ context 'when variables contain integers and symbols' do
+ let(:variables) do
+ { key1: 1, key2: :value2 }
+ end
- it { is_expected.to match_array(result) }
+ let(:result1) do
+ { 'key1' => '1', 'key2' => 'value2' }
end
+
+ it { is_expected.to eq(result1) }
end
end
@@ -126,35 +127,35 @@ RSpec.describe Gitlab::Ci::Variables::Helpers do
let(:inheritance) { true }
let(:result) do
- [{ key: 'key1', value: 'value1' },
- { key: 'key2', value: 'value22' },
- { key: 'key3', value: 'value3' }]
+ [{ key: 'key1', value: 'value1', public: true },
+ { key: 'key2', value: 'value22', public: true },
+ { key: 'key3', value: 'value3', public: true }]
end
subject { described_class.inherit_yaml_variables(from: from, to: to, inheritance: inheritance) }
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq(result) }
context 'when inheritance is false' do
let(:inheritance) { false }
let(:result) do
- [{ key: 'key2', value: 'value22' },
- { key: 'key3', value: 'value3' }]
+ [{ key: 'key2', value: 'value22', public: true },
+ { key: 'key3', value: 'value3', public: true }]
end
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq(result) }
end
context 'when inheritance is array' do
let(:inheritance) { ['key2'] }
let(:result) do
- [{ key: 'key2', value: 'value22' },
- { key: 'key3', value: 'value3' }]
+ [{ key: 'key2', value: 'value22', public: true },
+ { key: 'key3', value: 'value3', public: true }]
end
- it { is_expected.to match_array(result) }
+ it { is_expected.to eq(result) }
end
end
end