diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-16 15:10:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-16 15:10:05 +0000 |
commit | d872c89ce4828a16d72ddeed8695077fdcaf7b30 (patch) | |
tree | 1c982aed87c3bfb90a518970368b88257aecf2ab /spec/lib | |
parent | 09dff3eec735ccbe001d165293ecebf195452071 (diff) | |
download | gitlab-ce-d872c89ce4828a16d72ddeed8695077fdcaf7b30.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/rules_spec.rb | 72 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/bulk_importing_spec.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/logger_spec.rb | 4 |
4 files changed, 61 insertions, 23 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/rules_spec.rb b/spec/lib/gitlab/ci/config/entry/rules_spec.rb index 7d26365e7b3..91252378541 100644 --- a/spec/lib/gitlab/ci/config/entry/rules_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/rules_spec.rb @@ -17,6 +17,10 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do describe '.new' do subject { entry } + before do + subject.compose! + end + context 'with a list of rule rule' do let(:config) do [{ if: '$THIS == "that"', when: 'never' }] @@ -24,14 +28,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do it { is_expected.to be_a(described_class) } it { is_expected.to be_valid } - - context 'when composed' do - before do - subject.compose! - end - - it { is_expected.to be_valid } - end end context 'with a list of two rules' do @@ -42,21 +38,34 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do ] end - it { is_expected.to be_a(described_class) } it { is_expected.to be_valid } + end - context 'when composed' do - before do - subject.compose! - end + context 'with a single rule object' do + let(:config) do + { if: '$SKIP', when: 'never' } + end - it { is_expected.to be_valid } + it { is_expected.not_to be_valid } + end + + context 'with nested rules' do + let(:config) do + [ + { if: '$THIS == "that"', when: 'always' }, + [{ if: '$SKIP', when: 'never' }] + ] end + + it { is_expected.to be_valid } end - context 'with a single rule object' do + context 'with rules nested more than one level' do let(:config) do - { if: '$SKIP', when: 'never' } + [ + { if: '$THIS == "that"', when: 'always' }, + [{ if: '$SKIP', when: 'never' }, [{ if: '$THIS == "other"', when: 'aways' }]] + ] end it { is_expected.not_to be_valid } @@ -90,7 +99,36 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do { if: '$SKIP', when: 'never' } end - it { is_expected.to eq(config) } + it { is_expected.to eq([config]) } + end + + context 'with nested rules' do + let(:first_rule) { { if: '$THIS == "that"', when: 'always' } } + let(:second_rule) { { if: '$SKIP', when: 'never' } } + + let(:config) do + [ + first_rule, + [second_rule] + ] + end + + it { is_expected.to contain_exactly(first_rule, second_rule) } + end + + context 'with rules nested more than one level' do + let(:first_rule) { { if: '$THIS == "that"', when: 'always' } } + let(:second_rule) { { if: '$SKIP', when: 'never' } } + let(:third_rule) { { if: '$THIS == "other"', when: 'aways' } } + + let(:config) do + [ + first_rule, + [second_rule, [third_rule]] + ] + end + + it { is_expected.to contain_exactly(first_rule, second_rule, third_rule) } end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index dc443c5a1c1..49a470f9e01 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -2781,7 +2781,7 @@ module Gitlab expect(subject.valid?).to eq(false) expect(subject.errors).to contain_exactly( 'jobs:rspec config contains unknown keys: bad_tags', - 'jobs:rspec rules should be an array of hashes') + 'jobs:rspec rules should be an array containing hashes and arrays of hashes') end end diff --git a/spec/lib/gitlab/github_import/bulk_importing_spec.rb b/spec/lib/gitlab/github_import/bulk_importing_spec.rb index 5b08fce1e98..6c94973b5a8 100644 --- a/spec/lib/gitlab/github_import/bulk_importing_spec.rb +++ b/spec/lib/gitlab/github_import/bulk_importing_spec.rb @@ -36,7 +36,7 @@ RSpec.describe Gitlab::GithubImport::BulkImporting do expect(Gitlab::Import::Logger) .to receive(:info) .with( - import_source: :github, + import_type: :github, project_id: 1, importer: 'MyImporter', message: '1 object_types fetched' @@ -70,7 +70,7 @@ RSpec.describe Gitlab::GithubImport::BulkImporting do expect(Gitlab::Import::Logger) .to receive(:info) .with( - import_source: :github, + import_type: :github, project_id: 1, importer: 'MyImporter', message: '0 object_types fetched' @@ -100,7 +100,7 @@ RSpec.describe Gitlab::GithubImport::BulkImporting do .to receive(:info) .twice .with( - import_source: :github, + import_type: :github, project_id: 1, importer: 'MyImporter', message: '5 object_types imported' diff --git a/spec/lib/gitlab/github_import/logger_spec.rb b/spec/lib/gitlab/github_import/logger_spec.rb index e7e09505747..6fd0f5db93e 100644 --- a/spec/lib/gitlab/github_import/logger_spec.rb +++ b/spec/lib/gitlab/github_import/logger_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Gitlab::GithubImport::Logger do 'message' => 'Hello world', 'correlation_id' => 'new-correlation-id', 'feature_category' => 'importers', - 'import_source' => 'github' + 'import_type' => 'github' }) end @@ -34,7 +34,7 @@ RSpec.describe Gitlab::GithubImport::Logger do 'hello' => 1, 'correlation_id' => 'new-correlation-id', 'feature_category' => 'importers', - 'import_source' => 'github' + 'import_type' => 'github' }) end end |