diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /spec/lib/gitlab/ci/config/entry/need_spec.rb | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/need_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/need_spec.rb | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/need_spec.rb b/spec/lib/gitlab/ci/config/entry/need_spec.rb index ab2e8d4db78..eba9411560e 100644 --- a/spec/lib/gitlab/ci/config/entry/need_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/need_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ::Gitlab::Ci::Config::Entry::Need do +RSpec.describe ::Gitlab::Ci::Config::Entry::Need, feature_category: :pipeline_composition do subject(:need) { described_class.new(config) } shared_examples 'job type' do @@ -219,6 +219,81 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Need do it_behaves_like 'job type' end + + context 'when parallel:matrix has a value' do + before do + need.compose! + end + + context 'and it is a string value' do + let(:config) do + { job: 'job_name', parallel: { matrix: [{ platform: 'p1', stack: 's1' }] } } + end + + describe '#valid?' do + it { is_expected.to be_valid } + end + + describe '#value' do + it 'returns job needs configuration' do + expect(need.value).to eq( + name: 'job_name', + artifacts: true, + optional: false, + parallel: { matrix: [{ "platform" => ['p1'], "stack" => ['s1'] }] } + ) + end + end + + it_behaves_like 'job type' + end + + context 'and it is an array value' do + let(:config) do + { job: 'job_name', parallel: { matrix: [{ platform: %w[p1 p2], stack: %w[s1 s2] }] } } + end + + describe '#valid?' do + it { is_expected.to be_valid } + end + + describe '#value' do + it 'returns job needs configuration' do + expect(need.value).to eq( + name: 'job_name', + artifacts: true, + optional: false, + parallel: { matrix: [{ 'platform' => %w[p1 p2], 'stack' => %w[s1 s2] }] } + ) + end + end + + it_behaves_like 'job type' + end + + context 'and it is a both an array and string value' do + let(:config) do + { job: 'job_name', parallel: { matrix: [{ platform: %w[p1 p2], stack: 's1' }] } } + end + + describe '#valid?' do + it { is_expected.to be_valid } + end + + describe '#value' do + it 'returns job needs configuration' do + expect(need.value).to eq( + name: 'job_name', + artifacts: true, + optional: false, + parallel: { matrix: [{ 'platform' => %w[p1 p2], 'stack' => ['s1'] }] } + ) + end + end + + it_behaves_like 'job type' + end + end end context 'with cross pipeline artifacts needs' do |