From 8520abdfb6b44f7f6fbcc980524b1a5b1e57d4d8 Mon Sep 17 00:00:00 2001 From: Stephan Eicher Date: Sat, 13 Jul 2019 19:05:49 +0200 Subject: [PATCH 1/2] Simplify php (extension) removal --- manifests/extension.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/extension.pp b/manifests/extension.pp index 2fe4c7b1..6016089b 100644 --- a/manifests/extension.pp +++ b/manifests/extension.pp @@ -4,7 +4,7 @@ # # [*ensure*] # The ensure of the package to install -# Could be "latest", "installed" or a pinned version +# Could be "present", "absent", "latest", "installed" or a pinned version # # [*package_prefix*] # Prefix to prepend to the package name for the package provider @@ -71,7 +71,7 @@ # Array of String or Hash options to pass to the provider. # define php::extension ( - String $ensure = 'installed', + String $ensure = $php::ensure, Optional[Php::Provider] $provider = undef, Optional[String] $source = undef, Optional[String] $so_name = undef, From 6955747ac19fc09777fc8a6bed4a8ec4827b8d9a Mon Sep 17 00:00:00 2001 From: Stephan Eicher Date: Mon, 29 Jul 2019 15:42:12 +0200 Subject: [PATCH 2/2] Add test for simple removal feature --- spec/classes/php_spec.rb | 41 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index 63c6408e..412d1808 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -25,7 +25,7 @@ 'php5-cli' end end - php_fpm_ackage = case facts[:os]['name'] + php_fpm_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '9' @@ -43,7 +43,7 @@ 'php5-fpm' end end - php_dev_ackage = case facts[:os]['name'] + php_dev_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '9' @@ -75,8 +75,8 @@ it { is_expected.to contain_package('php-pear').with_ensure('present') } it { is_expected.to contain_class('php::composer') } it { is_expected.to contain_package(php_cli_package).with_ensure('present') } - it { is_expected.to contain_package(php_fpm_ackage).with_ensure('present') } - it { is_expected.to contain_package(php_dev_ackage).with_ensure('present') } + it { is_expected.to contain_package(php_fpm_package).with_ensure('present') } + it { is_expected.to contain_package(php_dev_package).with_ensure('present') } when 'Suse' it { is_expected.to contain_package('php5').with_ensure('present') } it { is_expected.to contain_package('php5-devel').with_ensure('present') } @@ -90,6 +90,39 @@ end end + describe 'when called with extensions' do + let(:params) { { extensions: { xml: {} } } } + + it { is_expected.to contain_php__extension('xml').with_ensure('present') } + end + + describe 'when called with ensure absent and extensions' do + let(:params) { + { + ensure: 'absent', + extensions: { + xml: { + } + } + } + } + + it { is_expected.to contain_php__extension('xml').with_ensure('absent') } + + case facts[:osfamily] + 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') } + it { is_expected.to contain_package(php_dev_package).with_ensure('absent') } + when 'Suse' + it { is_expected.to contain_package('php5').with_ensure('absent') } + it { is_expected.to contain_package('php5-devel').with_ensure('absent') } + when 'RedHat', 'CentOS' + it { is_expected.to contain_package('php-cli').with_ensure('absent') } + it { is_expected.to contain_package('php-common').with_ensure('absent') } + end + end + describe 'when called with package_prefix parameter' do package_prefix = 'myphp-' let(:params) { { package_prefix: package_prefix } }