Skip to content

Commit

Permalink
fix: RSpec issues
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Webb <[email protected]>
  • Loading branch information
damacus committed Dec 4, 2024
1 parent 858e71b commit 93010d2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require:
- cookstyle
2 changes: 1 addition & 1 deletion libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def repo_url(train = 'stable')
else
"#{repo_base_url}/amzn/#{node['platform_version'].to_i}/$basearch"
end
when 'centos'
when 'centos', 'centos-stream'
"#{repo_base_url}/centos/#{node['platform_version'].to_i}/$basearch"
when 'fedora'
"#{repo_base_url}/rhel/9/$basearch"
Expand Down
24 changes: 12 additions & 12 deletions spec/support/install.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def platform_repo_url
case chefspec_platform
when 'fedora', 'redhat'
'https://nginx.org/packages/rhel/7/$basearch'
'https://nginx.org/packages/rhel/8/$basearch'
when 'amazon'
'https://nginx.org/packages/amzn/2018/$basearch'
when 'centos'
'https://nginx.org/packages/centos/8/$basearch'
'https://nginx.org/packages/amzn/2023/$basearch'
when 'centos-stream'
'https://nginx.org/packages/centos/9/$basearch'
when 'debian'
'https://nginx.org/packages/debian'
when 'opensuse'
Expand All @@ -22,9 +22,9 @@ def repo_signing_key
def platform_distribution_nginx
case chefspec_platform
when 'debian'
'bullseye'
'bookworm'
when 'ubuntu'
'focal'
'noble'
end
end

Expand All @@ -46,10 +46,10 @@ def nginx_user
end
end

def debian_9?
chefspec_platform == 'debian' && chefspec_platform_version.to_i == 9
end
# def debian_9?
# chefspec_platform == 'debian' && chefspec_platform_version.to_i == 9
# end

def ubuntu_18?
chefspec_platform == 'ubuntu' && chefspec_platform_version.to_f == 18.04
end
# def ubuntu_18?
# chefspec_platform == 'ubuntu' && chefspec_platform_version.to_f == 18.04
# end
4 changes: 2 additions & 2 deletions spec/unit/libraries/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DummyClass < Chef::Node
let(:platform_version) { '7' }

context 'with centos platform stable' do
let(:platform) { 'centos' }
let(:platform) { 'centos-stream' }

it { expect(subject.repo_url).to eq 'https://nginx.org/packages/centos/7/$basearch' }
end
Expand Down Expand Up @@ -125,7 +125,7 @@ class DummyClass < Chef::Node
let(:platform_version) { '7' }

context 'with centos platform mainline' do
let(:platform) { 'centos' }
let(:platform) { 'centos-stream' }

it { expect(subject.repo_url('mainline')).to eq 'https://nginx.org/packages/mainline/centos/7/$basearch' }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/resources/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx_config' do
step_into :nginx_config, :nginx_install, :nginx_site
platform 'centos'
platform 'centos-stream'

before do
stub_command('/usr/sbin/nginx -t').and_return(true)
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/resources/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx_install' do
step_into :nginx_install
platform 'centos'
platform 'centos-stream'

before do
stub_command('dnf module list nginx | grep -q "^nginx.*\\[x\\]"').and_return(false)
Expand Down Expand Up @@ -90,7 +90,7 @@
end

context 'with centos platform' do
platform 'centos'
platform 'centos-stream'

let(:package_install_options) { ['--disablerepo=*', '--enablerepo=nginx'] }

Expand Down Expand Up @@ -149,8 +149,8 @@
it { is_expected.to run_execute('amazon-linux-extras install epel') }
end

context 'with centos 7 platform' do
platform 'centos', '7.7.1908'
context 'with centos-stream 9 platform' do
platform 'centos-stream', '9'

include_examples 'ohai is enabled'
include_examples 'nginx package is installed'
Expand All @@ -159,7 +159,7 @@
end

context 'with centos 8 platform' do
platform 'centos', '8'
platform 'centos-stream', '8'

include_examples 'ohai is enabled'
include_examples 'nginx package is installed'
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/resources/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx_service' do
step_into :nginx_service
platform 'centos'
platform 'centos-stream'

context 'configure nginx service' do
recipe do
Expand Down

0 comments on commit 93010d2

Please sign in to comment.