From ca5ce9628488579cf14289c33ec78ada0655e367 Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sat, 5 Oct 2019 14:59:33 +0200 Subject: [PATCH 1/9] REFACTOR separate tests: applies without error / applies idempotently --- spec/acceptance/php_spec.rb | 46 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 01ab0a5c..dbc09101 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -2,10 +2,11 @@ describe 'php with default settings' do context 'default parameters' do - it 'works with defaults' do - pp = 'include php' - # Run it twice and test for idempotency + pp = 'include php' + it 'applies without error' do apply_manifest(pp, catch_failures: true) + end + it 'applies idempotently' do apply_manifest(pp, catch_changes: true) end @@ -37,14 +38,13 @@ context 'default parameters with extensions' do case default[:platform] when %r{ubuntu-18.04}, %r{ubuntu-16.04} - it 'works with defaults' do - case default[:platform] - when %r{ubuntu-18.04} - simplexmlpackagename = 'php7.2-xml' - when %r{ubuntu-16.04} - simplexmlpackagename = 'php7.0-xml' - end - pp = <<-EOS + case default[:platform] + when %r{ubuntu-18.04} + simplexmlpackagename = 'php7.2-xml' + when %r{ubuntu-16.04} + simplexmlpackagename = 'php7.0-xml' + end + pp = <<-EOS class{'php': extensions => { 'mysql' => {}, @@ -60,14 +60,15 @@ } } } - EOS - # Run it twice and test for idempotency + EOS + it 'applies without error' do apply_manifest(pp, catch_failures: true) + end + it 'applies idempotently' do apply_manifest(pp, catch_changes: true) end when %r{ubuntu-14.04} - it 'works with defaults' do - pp = <<-EOS + pp = <<-EOS class{'php': extensions => { 'mysql' => {}, @@ -80,23 +81,26 @@ } } } - EOS - # Run it twice and test for idempotency + EOS + it 'applies without error' do apply_manifest(pp, catch_failures: true) + end + it 'applies idempotently' do apply_manifest(pp, catch_changes: true) end else - it 'works with defaults' do - pp = <<-EOS + pp = <<-EOS class{'php': extensions => { 'mysql' => {}, 'gd' => {} } } - EOS - # Run it twice and test for idempotency + EOS + it 'applies without error' do apply_manifest(pp, catch_failures: true) + end + it 'applies idempotently' do apply_manifest(pp, catch_changes: true) end end From 860fb2284baf7214f3e76a80bec2b8b934b84af7 Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sat, 5 Oct 2019 16:13:55 +0200 Subject: [PATCH 2/9] STYLE Give more explicit name to tasks --- spec/acceptance/php_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index dbc09101..debe371b 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper_acceptance' -describe 'php with default settings' do - context 'default parameters' do +describe 'php class' do + context 'with default parameters' do pp = 'include php' it 'applies without error' do apply_manifest(pp, catch_failures: true) @@ -35,7 +35,7 @@ it { is_expected.to be_enabled } end end - context 'default parameters with extensions' do + context 'with extensions' do case default[:platform] when %r{ubuntu-18.04}, %r{ubuntu-16.04} case default[:platform] From d9af17602d2d0df383b86020dce3fc5cf3e64a91 Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sat, 5 Oct 2019 16:38:13 +0200 Subject: [PATCH 3/9] FIX Rubocop issues ont acceptance code --- spec/acceptance/php_spec.rb | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index debe371b..6b3be0dc 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -61,12 +61,6 @@ } } EOS - it 'applies without error' do - apply_manifest(pp, catch_failures: true) - end - it 'applies idempotently' do - apply_manifest(pp, catch_changes: true) - end when %r{ubuntu-14.04} pp = <<-EOS class{'php': @@ -82,12 +76,6 @@ } } EOS - it 'applies without error' do - apply_manifest(pp, catch_failures: true) - end - it 'applies idempotently' do - apply_manifest(pp, catch_changes: true) - end else pp = <<-EOS class{'php': @@ -97,12 +85,13 @@ } } EOS - it 'applies without error' do - apply_manifest(pp, catch_failures: true) - end - it 'applies idempotently' do - apply_manifest(pp, catch_changes: true) - end + end + + it 'applies without error' do + apply_manifest(pp, catch_failures: true) + end + it 'applies idempotently' do + apply_manifest(pp, catch_changes: true) end case default[:platform] From cc7628b5656540eb6f52abf490073fee18d39a85 Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sat, 5 Oct 2019 17:18:56 +0200 Subject: [PATCH 4/9] REFACTOR Reorganise logic of case on platforms --- spec/acceptance/php_spec.rb | 87 ++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 6b3be0dc..117f867b 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -36,57 +36,53 @@ end end context 'with extensions' do - case default[:platform] - when %r{ubuntu-18.04}, %r{ubuntu-16.04} - case default[:platform] - when %r{ubuntu-18.04} - simplexmlpackagename = 'php7.2-xml' - when %r{ubuntu-16.04} - simplexmlpackagename = 'php7.0-xml' - end - pp = <<-EOS - class{'php': - extensions => { - 'mysql' => {}, - 'gd' => {}, - 'net-url' => { - package_prefix => 'php-', - settings => { - extension => undef - }, - }, - 'simplexml' => { - package_name => '#{simplexmlpackagename}', - } - } - } - EOS - when %r{ubuntu-14.04} - pp = <<-EOS + added_extensions = case default[:platform] + when %r{ubuntu-18.04} + <<-EOS + 'net-url' => { + package_prefix => 'php-', + settings => { + extension => undef + }, + }, + 'simplexml' => { + package_name => 'php7.2-xml', + }, + EOS + when %r{ubuntu-16.04} + <<-EOS + 'net-url' => { + package_prefix => 'php-', + settings => { + extension => undef + }, + }, + 'simplexml' => { + package_name => 'php7.0-xml', + }, + EOS + when %r{ubuntu-14.04} + <<-EOS + 'net-url' => { + package_prefix => 'php-', + settings => { + extension => undef + }, + }, + EOS + else + '' + end + + pp = <<-EOS class{'php': extensions => { 'mysql' => {}, 'gd' => {}, - 'net-url' => { - package_prefix => 'php-', - settings => { - extension => undef - }, - } + #{added_extensions} } } - EOS - else - pp = <<-EOS - class{'php': - extensions => { - 'mysql' => {}, - 'gd' => {} - } - } - EOS - end - + EOS it 'applies without error' do apply_manifest(pp, catch_failures: true) end @@ -110,6 +106,7 @@ when %r{debian-10} packagename = 'php7.3-fpm' end + describe package(packagename) do it { is_expected.to be_installed } end From 669ada0fa846548d4e6d139144492bfebd6fcf92 Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sat, 5 Oct 2019 17:20:19 +0200 Subject: [PATCH 5/9] CHORE Add 13 php extensions on Ubuntu 18.04 acceptance test --- spec/acceptance/php_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 117f867b..476b9a94 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -39,6 +39,20 @@ added_extensions = case default[:platform] when %r{ubuntu-18.04} <<-EOS + 'apcu' => {}, + 'bz2' => {}, + 'ctype' => {}, + 'curl' => {}, + 'dom' => {}, + 'iconv' => {}, + 'imagick' => {}, + 'intl' => {}, + 'json' => {}, + 'mbstring' => {}, + 'posix' => {}, + 'xmlreader' => {}, + 'xmlwriter' => {}, + 'zip' => {}, 'net-url' => { package_prefix => 'php-', settings => { From 322739d6b79c3b47460f8bd830c92f32db4b4c8c Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sat, 5 Oct 2019 20:11:46 +0200 Subject: [PATCH 6/9] CHORE Lower from 13 to 6 extensions on Ubuntu 18.04 acceptance test --- spec/acceptance/php_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 476b9a94..298a3b8e 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -39,19 +39,11 @@ added_extensions = case default[:platform] when %r{ubuntu-18.04} <<-EOS - 'apcu' => {}, 'bz2' => {}, - 'ctype' => {}, 'curl' => {}, - 'dom' => {}, - 'iconv' => {}, - 'imagick' => {}, 'intl' => {}, 'json' => {}, 'mbstring' => {}, - 'posix' => {}, - 'xmlreader' => {}, - 'xmlwriter' => {}, 'zip' => {}, 'net-url' => { package_prefix => 'php-', From 38b353f9408f260b297b4a599244742721967516 Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sun, 6 Oct 2019 10:07:37 +0200 Subject: [PATCH 7/9] CHORE Lower from 13 to 1 (more) extension on Ubuntu 18.04 acceptance test --- spec/acceptance/php_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 298a3b8e..3d7f0dd7 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -40,11 +40,6 @@ when %r{ubuntu-18.04} <<-EOS 'bz2' => {}, - 'curl' => {}, - 'intl' => {}, - 'json' => {}, - 'mbstring' => {}, - 'zip' => {}, 'net-url' => { package_prefix => 'php-', settings => { From 23b227a06d1b07a07137bcfe3d1b608f25893245 Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sun, 6 Oct 2019 10:40:51 +0200 Subject: [PATCH 8/9] CHORE Get back to 6 extensions more --- spec/acceptance/php_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 3d7f0dd7..298a3b8e 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -40,6 +40,11 @@ when %r{ubuntu-18.04} <<-EOS 'bz2' => {}, + 'curl' => {}, + 'intl' => {}, + 'json' => {}, + 'mbstring' => {}, + 'zip' => {}, 'net-url' => { package_prefix => 'php-', settings => { From c6e62b54c1187cabb846c0397756eba934f0cc9f Mon Sep 17 00:00:00 2001 From: Matthieu FAURE Date: Sun, 6 Oct 2019 11:12:42 +0200 Subject: [PATCH 9/9] CHORE Acceptance: add php extension xmlreader --- spec/acceptance/php_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 298a3b8e..8d95518b 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -44,6 +44,7 @@ 'intl' => {}, 'json' => {}, 'mbstring' => {}, + 'xmlreader' => {}, 'zip' => {}, 'net-url' => { package_prefix => 'php-',