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:
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/need_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/entry/need_spec.rb77
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