Skip to content

Commit 1c59300

Browse files
stanhubalasankarc
authored andcommitted
Make spec/lib/gitlab/build/check_spec.rb work when ee value is set
If a pipeline is run with the `ee=true` environment set, then previously the spec would fail (https://gitlab.com/gitlab-org/omnibus-gitlab/-/jobs/5480966109). Let's fix this by ensuring the environment variable is stubbed to nil.
1 parent a489b4e commit 1c59300

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

spec/lib/gitlab/build/check_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
end
2525

2626
it 'when env variable is not set' do
27+
stub_env_var('ee', nil)
2728
stub_is_ee_version(false)
2829
stub_is_auto_deploy(false)
2930
expect(described_class.is_ee?).to be_falsy
@@ -32,11 +33,13 @@
3233

3334
describe 'GITLAB_VERSION variable' do
3435
it 'when GITLAB_VERSION ends with -ee' do
36+
stub_env_var('ee', nil)
3537
stub_env_var('GITLAB_VERSION', 'foo-ee')
3638
expect(described_class.is_ee?).to be_truthy
3739
end
3840

3941
it 'when GITLAB_VERSION does not end with -ee' do
42+
stub_env_var('ee', nil)
4043
stub_env_var('GITLAB_VERSION', 'foo')
4144
stub_is_auto_deploy(false)
4245
expect(described_class.is_ee?).to be_falsy

spec/lib/gitlab/build/info/components_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
# On stable branches and tags, generate-facts will not populate version facts
3131
# So, the content of the VERSION file will be used as-is.
3232
it 'returns tag with v prefix' do
33-
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(false)
33+
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(false)
3434
allow(File).to receive(:read).with(/VERSION/).and_return('15.7.0')
3535
expect(described_class.ref).to eq('v15.7.0')
3636
end
3737
end
3838

3939
context 'when on feature branches' do
4040
it 'returns commit SHA without any prefix' do
41-
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(true)
42-
allow(File).to receive(:read).with(/gitlab-rails_version/).and_return('arandomcommit')
41+
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(true)
42+
allow(File).to receive(:read).with(/gitlab-rails.*version/).and_return('arandomcommit')
4343
expect(described_class.ref).to eq('arandomcommit')
4444
end
4545
end
@@ -50,16 +50,16 @@
5050
# On stable branches and tags, generate-facts will not populate version facts
5151
# So, whatever is on VERSION file, will be used.
5252
it 'returns tag without v prefix' do
53-
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(false)
53+
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(false)
5454
allow(File).to receive(:read).with(/VERSION/).and_return('15.7.0')
5555
expect(described_class.ref(prepend_version: false)).to eq('15.7.0')
5656
end
5757
end
5858

5959
context 'when on feature branches' do
6060
it 'returns commit SHA without any prefix' do
61-
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(true)
62-
allow(File).to receive(:read).with(/gitlab-rails_version/).and_return('arandomcommit')
61+
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(true)
62+
allow(File).to receive(:read).with(/gitlab-rails.*version/).and_return('arandomcommit')
6363
expect(described_class.ref(prepend_version: false)).to eq('arandomcommit')
6464
end
6565
end

0 commit comments

Comments
 (0)