From 075ea1afdd4d3dcc9238160acae37fad17c341c3 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Sun, 1 Sep 2024 01:10:38 +0200 Subject: [PATCH] replace legacy facts --- spec/classes/php_fpm_service_spec.rb | 4 ++-- spec/classes/php_fpm_spec.rb | 4 ++-- spec/classes/php_repo_spec.rb | 4 ++-- spec/classes/php_spec.rb | 22 +++++++++++----------- spec/defines/extension_rhscl_spec.rb | 2 +- spec/defines/extension_spec.rb | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/classes/php_fpm_service_spec.rb b/spec/classes/php_fpm_service_spec.rb index a364a9f0..39df3cee 100644 --- a/spec/classes/php_fpm_service_spec.rb +++ b/spec/classes/php_fpm_service_spec.rb @@ -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' diff --git a/spec/classes/php_fpm_spec.rb b/spec/classes/php_fpm_spec.rb index 7df13cf4..04d13e43 100644 --- a/spec/classes/php_fpm_spec.rb +++ b/spec/classes/php_fpm_spec.rb @@ -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') } diff --git a/spec/classes/php_repo_spec.rb b/spec/classes/php_repo_spec.rb index 55faf500..2f14098d 100644 --- a/spec/classes/php_repo_spec.rb +++ b/spec/classes/php_repo_spec.rb @@ -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' diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index ce687b10..4dfed58f 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -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') } @@ -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') } @@ -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') } @@ -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' @@ -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' @@ -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' @@ -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' @@ -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 { diff --git a/spec/defines/extension_rhscl_spec.rb b/spec/defines/extension_rhscl_spec.rb index 197ef173..7fdfc95d 100644 --- a/spec/defines/extension_rhscl_spec.rb +++ b/spec/defines/extension_rhscl_spec.rb @@ -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 diff --git a/spec/defines/extension_spec.rb b/spec/defines/extension_spec.rb index 3668ff4f..28ecf6d1 100644 --- a/spec/defines/extension_spec.rb +++ b/spec/defines/extension_spec.rb @@ -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']