diff options
Diffstat (limited to 'spec/lib/gitlab/ci/config')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/job_spec.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/jobs_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/root_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb | 21 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/normalizer_spec.rb | 26 |
5 files changed, 24 insertions, 47 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index ca02eaee0a0..ab760b107f8 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -74,16 +74,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do it { is_expected.to be_falsey } end - context 'when config does not contain script' do - let(:name) { :build } - - let(:config) do - { before_script: "cd ${PROJ_DIR} " } - end - - it { is_expected.to be_truthy } - end - context 'when using the default job without script' do let(:name) { :default } let(:config) do @@ -104,14 +94,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do it { is_expected.to be_truthy } end - - context 'there are no shared keys between jobs and bridges' do - subject(:shared_values) do - described_class::ALLOWED_KEYS & Gitlab::Ci::Config::Entry::Bridge::ALLOWED_KEYS - end - - it { is_expected.to be_empty } - end end describe 'validations' do diff --git a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb index 8561bd330b7..ac6b589ec6b 100644 --- a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb @@ -68,7 +68,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Jobs do let(:config) { { rspec: nil } } it 'reports error' do - expect(entry.errors).to include "jobs config should contain valid jobs" + expect(entry.errors).to include 'jobs rspec config should implement a script: or a trigger: keyword' end end diff --git a/spec/lib/gitlab/ci/config/entry/root_spec.rb b/spec/lib/gitlab/ci/config/entry/root_spec.rb index 140b3c4f55b..252bda6461d 100644 --- a/spec/lib/gitlab/ci/config/entry/root_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/root_spec.rb @@ -344,9 +344,9 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do end describe '#errors' do - it 'reports errors about missing script' do + it 'reports errors about missing script or trigger' do expect(root.errors) - .to include "root config contains unknown keys: rspec" + .to include 'jobs rspec config should implement a script: or a trigger: keyword' end end end diff --git a/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb b/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb index bab604c4504..fbf86927bd9 100644 --- a/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb +++ b/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb @@ -43,7 +43,7 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do expect(subject.map(&:attributes)).to match_array( [ { - name: 'test 1/4', + name: 'test: [aws, app1]', instance: 1, parallel: { total: 4 }, variables: { @@ -52,7 +52,7 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do } }, { - name: 'test 2/4', + name: 'test: [aws, app2]', instance: 2, parallel: { total: 4 }, variables: { @@ -61,7 +61,7 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do } }, { - name: 'test 3/4', + name: 'test: [ovh, app]', instance: 3, parallel: { total: 4 }, variables: { @@ -70,7 +70,7 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do } }, { - name: 'test 4/4', + name: 'test: [gcp, app]', instance: 4, parallel: { total: 4 }, variables: { @@ -84,18 +84,7 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do it 'has parallelized name' do expect(subject.map(&:name)).to match_array( - ['test 1/4', 'test 2/4', 'test 3/4', 'test 4/4'] - ) - end - - it 'has details' do - expect(subject.map(&:name_with_details)).to match_array( - [ - 'test (PROVIDER=aws; STACK=app1)', - 'test (PROVIDER=aws; STACK=app2)', - 'test (PROVIDER=gcp; STACK=app)', - 'test (PROVIDER=ovh; STACK=app)' - ] + ['test: [aws, app1]', 'test: [aws, app2]', 'test: [gcp, app]', 'test: [ovh, app]'] ) end end diff --git a/spec/lib/gitlab/ci/config/normalizer_spec.rb b/spec/lib/gitlab/ci/config/normalizer_spec.rb index 949af8cdc4c..4c19657413c 100644 --- a/spec/lib/gitlab/ci/config/normalizer_spec.rb +++ b/spec/lib/gitlab/ci/config/normalizer_spec.rb @@ -178,8 +178,8 @@ RSpec.describe Gitlab::Ci::Config::Normalizer do { matrix: [ { - VAR_1: [1], - VAR_2: [2, 3] + VAR_1: ['A'], + VAR_2: %w[B C] } ] } @@ -187,8 +187,8 @@ RSpec.describe Gitlab::Ci::Config::Normalizer do let(:expanded_job_names) do [ - 'rspec 1/2', - 'rspec 2/2' + 'rspec: [A, B]', + 'rspec: [A, C]' ] end @@ -196,21 +196,17 @@ RSpec.describe Gitlab::Ci::Config::Normalizer do is_expected.not_to include(job_name) end - it 'has parallelized jobs' do - is_expected.to include(*expanded_job_names.map(&:to_sym)) - end - it 'sets job instance in options' do expect(subject.values).to all(include(:instance)) end it 'sets job variables', :aggregate_failures do expect(subject.values[0]).to match( - a_hash_including(variables: { VAR_1: 1, VAR_2: 2, USER_VARIABLE: 'user value' }) + a_hash_including(variables: { VAR_1: 'A', VAR_2: 'B', USER_VARIABLE: 'user value' }) ) expect(subject.values[1]).to match( - a_hash_including(variables: { VAR_1: 1, VAR_2: 3, USER_VARIABLE: 'user value' }) + a_hash_including(variables: { VAR_1: 'A', VAR_2: 'C', USER_VARIABLE: 'user value' }) ) end @@ -226,6 +222,10 @@ RSpec.describe Gitlab::Ci::Config::Normalizer do expect(configs).to all(match(a_hash_including(original_config))) end + it 'has parallelized jobs' do + is_expected.to include(*expanded_job_names.map(&:to_sym)) + end + it_behaves_like 'parallel dependencies' it_behaves_like 'parallel needs' end @@ -238,5 +238,11 @@ RSpec.describe Gitlab::Ci::Config::Normalizer do is_expected.to match(config) end end + + context 'when jobs config is nil' do + let(:config) { nil } + + it { is_expected.to eq({}) } + end end end |