Skip to content
Snippets Groups Projects
Commit e54b486a authored by Stan Hu's avatar Stan Hu
Browse files

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.
parent 33ce6868
3 merge requests!119heptapod#1448: making Heptapod 1.1 the new oldstable,!116heptapod#1395: make 1.1 the new stable,!115Merged upstream 16.7 stable branches first commit
......@@ -24,6 +24,7 @@
end
it 'when env variable is not set' do
stub_env_var('ee', nil)
stub_is_ee_version(false)
stub_is_auto_deploy(false)
expect(described_class.is_ee?).to be_falsy
......@@ -32,8 +33,9 @@
describe 'GITLAB_VERSION variable' do
it 'when GITLAB_VERSION ends with -ee' do
stub_env_var('ee', nil)
stub_env_var('GITLAB_VERSION', 'foo-ee')
expect(described_class.is_ee?).to be_truthy
end
it 'when GITLAB_VERSION does not end with -ee' do
......@@ -35,8 +37,9 @@
stub_env_var('GITLAB_VERSION', 'foo-ee')
expect(described_class.is_ee?).to be_truthy
end
it 'when GITLAB_VERSION does not end with -ee' do
stub_env_var('ee', nil)
stub_env_var('GITLAB_VERSION', 'foo')
stub_is_auto_deploy(false)
expect(described_class.is_ee?).to be_falsy
......
......@@ -30,7 +30,7 @@
# On stable branches and tags, generate-facts will not populate version facts
# So, the content of the VERSION file will be used as-is.
it 'returns tag with v prefix' do
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(false)
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(false)
allow(File).to receive(:read).with(/VERSION/).and_return('15.7.0')
expect(described_class.ref).to eq('v15.7.0')
end
......@@ -38,8 +38,8 @@
context 'when on feature branches' do
it 'returns commit SHA without any prefix' do
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(true)
allow(File).to receive(:read).with(/gitlab-rails_version/).and_return('arandomcommit')
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(true)
allow(File).to receive(:read).with(/gitlab-rails.*version/).and_return('arandomcommit')
expect(described_class.ref).to eq('arandomcommit')
end
end
......@@ -50,7 +50,7 @@
# On stable branches and tags, generate-facts will not populate version facts
# So, whatever is on VERSION file, will be used.
it 'returns tag without v prefix' do
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(false)
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(false)
allow(File).to receive(:read).with(/VERSION/).and_return('15.7.0')
expect(described_class.ref(prepend_version: false)).to eq('15.7.0')
end
......@@ -58,8 +58,8 @@
context 'when on feature branches' do
it 'returns commit SHA without any prefix' do
allow(File).to receive(:exist?).with(/gitlab-rails_version/).and_return(true)
allow(File).to receive(:read).with(/gitlab-rails_version/).and_return('arandomcommit')
allow(File).to receive(:exist?).with(/gitlab-rails.*version/).and_return(true)
allow(File).to receive(:read).with(/gitlab-rails.*version/).and_return('arandomcommit')
expect(described_class.ref(prepend_version: false)).to eq('arandomcommit')
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment