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-11-25 18:09:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-25 18:09:28 +0300
commit35e5a7c8455f916bc969ec814c74cefd98d24f19 (patch)
tree4207bc732ad87cc5666c8ce446502f2d68860c4e /spec/lib/gitlab/ci/config
parent89474d2468f108c909e440efcbe2ce9f7090d19a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci/config')
-rw-r--r--spec/lib/gitlab/ci/config/entry/hooks_spec.rb37
-rw-r--r--spec/lib/gitlab/ci/config/entry/job_spec.rb27
2 files changed, 62 insertions, 2 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/hooks_spec.rb b/spec/lib/gitlab/ci/config/entry/hooks_spec.rb
new file mode 100644
index 00000000000..7a5ff244e18
--- /dev/null
+++ b/spec/lib/gitlab/ci/config/entry/hooks_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+RSpec.describe Gitlab::Ci::Config::Entry::Hooks do
+ subject(:entry) { described_class.new(config) }
+
+ before do
+ entry.compose!
+ end
+
+ describe 'validations' do
+ context 'when passing a valid hook' do
+ let(:config) { { pre_get_sources_script: ['ls'] } }
+
+ it { is_expected.to be_valid }
+ end
+
+ context 'when passing an invalid hook' do
+ let(:config) { { x_get_something: ['ls'] } }
+
+ it { is_expected.not_to be_valid }
+ end
+
+ context 'when entry config is not a hash' do
+ let(:config) { 'ls' }
+
+ it { is_expected.not_to be_valid }
+ end
+ end
+
+ describe '#value' do
+ let(:config) { { pre_get_sources_script: ['ls'] } }
+
+ it 'returns a hash' do
+ expect(entry.value).to eq(config)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb
index 22cb1f480c5..becb46ac2e7 100644
--- a/spec/lib/gitlab/ci/config/entry/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
subject { described_class.nodes.keys }
let(:result) do
- %i[before_script script stage after_script cache
+ %i[before_script script after_script hooks stage cache
image services only except rules needs variables artifacts
environment coverage retry interruptible timeout release tags
inherit parallel]
@@ -717,7 +717,8 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
{ before_script: %w[ls pwd],
script: 'rspec',
after_script: %w[cleanup],
- id_tokens: { TEST_ID_TOKEN: { aud: 'https://gitlab.com' } } }
+ id_tokens: { TEST_ID_TOKEN: { aud: 'https://gitlab.com' } },
+ hooks: { pre_get_sources_script: 'echo hello' } }
end
it 'returns correct value' do
@@ -728,12 +729,34 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
stage: 'test',
ignore: false,
after_script: %w[cleanup],
+ hooks: { pre_get_sources_script: ['echo hello'] },
only: { refs: %w[branches tags] },
job_variables: {},
root_variables_inheritance: true,
scheduling_type: :stage,
id_tokens: { TEST_ID_TOKEN: { aud: 'https://gitlab.com' } })
end
+
+ context 'when the FF ci_hooks_pre_get_sources_script is disabled' do
+ before do
+ stub_feature_flags(ci_hooks_pre_get_sources_script: false)
+ end
+
+ it 'returns correct value' do
+ expect(entry.value)
+ .to eq(name: :rspec,
+ before_script: %w[ls pwd],
+ script: %w[rspec],
+ stage: 'test',
+ ignore: false,
+ after_script: %w[cleanup],
+ only: { refs: %w[branches tags] },
+ job_variables: {},
+ root_variables_inheritance: true,
+ scheduling_type: :stage,
+ id_tokens: { TEST_ID_TOKEN: { aud: 'https://gitlab.com' } })
+ end
+ end
end
end