Skip to content

Commit

Permalink
replace legacy facts
Browse files Browse the repository at this point in the history
  • Loading branch information
zilchms committed Aug 31, 2024
1 parent a0c87df commit 075ea1a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions spec/classes/php_fpm_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
end

describe 'when called with no parameters' do
case facts[:osfamily]
case facts[:os]['family']
when 'Debian'
case facts[:operatingsystemrelease]
case facts[:os]['release']['major']
when '18.04'
it { is_expected.to contain_service('php7.2-fpm').with_ensure('running') }
when '22.04'
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/php_fpm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

describe 'when called with no parameters' do
# rubocop:disable RSpec/RepeatedExample
case facts[:osfamily]
case facts[:os]['family']
when 'Debian'
case facts[:operatingsystemrelease]
case facts[:os]['release']['major']
when '18.04'
it { is_expected.to contain_package('php7.2-fpm').with_ensure('present') }
it { is_expected.to contain_service('php7.2-fpm').with_ensure('running') }
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/php_repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
end

describe 'when configuring a package repo' do
case facts[:osfamily]
case facts[:os]['family']
when 'Debian'
case facts[:operatingsystem]
case facts[:os]['name']
when 'Debian'
it { is_expected.to contain_class('php::repo::debian') }
when 'Ubuntu'
Expand Down
22 changes: 11 additions & 11 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@
end

describe 'when called with no parameters' do
case facts[:osfamily]
case facts[:os]['family']
when 'Suse', 'RedHat', 'CentOS'
it { is_expected.to contain_class('php::global') }
end

case facts[:osfamily]
case facts[:os]['family']
when 'Debian'
it { is_expected.not_to contain_class('php::global') }
it { is_expected.to contain_class('php::fpm') }
Expand Down Expand Up @@ -125,7 +125,7 @@

it { is_expected.to contain_php__extension('xml').with_ensure('absent') }

case facts[:osfamily]
case facts[:os]['family']
when 'Debian'
it { is_expected.to contain_package(php_cli_package).with_ensure('absent') }
it { is_expected.to contain_package(php_fpm_package).with_ensure('absent') }
Expand All @@ -143,17 +143,17 @@
package_prefix = 'myphp-'
let(:params) { { package_prefix: package_prefix } }

case facts[:osfamily]
case facts[:os]['family']
when 'Suse', 'RedHat', 'CentOS'
it { is_expected.to contain_class('php::global') }
end

case facts[:osfamily]
case facts[:os]['family']
when 'Debian', 'RedHat', 'CentOS'
it { is_expected.to contain_package("#{package_prefix}cli").with_ensure('present') }
end

case facts[:osfamily]
case facts[:os]['family']
when 'Debian'
it { is_expected.not_to contain_class('php::global') }
it { is_expected.to contain_class('php::fpm') }
Expand All @@ -179,7 +179,7 @@
it { is_expected.to contain_class('php::fpm').with(user: 'nginx') }
it { is_expected.to contain_php__fpm__pool('www').with(user: 'nginx') }

dstfile = case facts[:osfamily]
dstfile = case facts[:os]['family']
when 'Debian'
case facts[:os]['name']
when 'Debian'
Expand Down Expand Up @@ -224,7 +224,7 @@
it { is_expected.to contain_class('php::fpm').with(group: 'nginx') }
it { is_expected.to contain_php__fpm__pool('www').with(group: 'nginx') }

dstfile = case facts[:osfamily]
dstfile = case facts[:os]['family']
when 'Debian'
case facts[:os]['name']
when 'Debian'
Expand Down Expand Up @@ -276,7 +276,7 @@

it { is_expected.to contain_php__fpm__pool('www').with(apparmor_hat: 'www') }

dstfile = case facts[:osfamily]
dstfile = case facts[:os]['family']
when 'Debian'
case facts[:os]['name']
when 'Debian'
Expand Down Expand Up @@ -327,7 +327,7 @@
it { is_expected.not_to contain_class('php::composer') }
end

if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS' || facts[:os]['name'] == 'Ubuntu' || (facts[:os]['name'] == 'Debian' && facts[:os]['release']['major'].to_i < 12)
if facts[:os]['family'] == 'RedHat' || facts[:os]['family'] == 'CentOS' || facts[:os]['name'] == 'Ubuntu' || (facts[:os]['name'] == 'Debian' && facts[:os]['release']['major'].to_i < 12)
describe 'when called with flavor zend' do
zendphp_cli_package = case facts[:os]['name']
when 'Debian', 'Ubuntu'
Expand Down Expand Up @@ -355,7 +355,7 @@
end
end

if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS'
if facts[:os]['family'] == 'RedHat' || facts[:os]['family'] == 'CentOS'
describe 'when called with valid settings parameter types' do
let(:params) do
{
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/extension_rhscl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe 'php::extension' do
on_supported_os.each do |os, facts|
next unless facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS'
next unless facts[:os]['family'] == 'RedHat' || facts[:os]['family'] == 'CentOS'

context "on #{os}" do
let :facts do
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
end
let(:pre_condition) { 'include php' }

unless facts[:osfamily] == 'Suse' || facts[:osfamily] == 'FreeBSD' # FIXME: something is wrong on these
unless facts[:os]['family'] == 'Suse' || facts[:os]['family'] == 'FreeBSD' # FIXME: something is wrong on these
etcdir = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
Expand Down

0 comments on commit 075ea1a

Please sign in to comment.