From adaae52f38f07fc2c7fd322c738f21607dacba37 Mon Sep 17 00:00:00 2001 From: Frank Wall Date: Mon, 31 Jul 2023 18:04:21 +0200 Subject: [PATCH] fix $install_enabled=false, closes #11 --- manifests/update.pp | 22 +++++++++---------- spec/classes/nextcloud_spec.rb | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/manifests/update.pp b/manifests/update.pp index 6fce4c4..b5ef921 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -3,18 +3,18 @@ class nextcloud::update { assert_private() - # Only perform update tasks if this feature is enabled. - if ($nextcloud::update_enabled =~ Boolean) { - # Commands and files required when performing an update. - $update_lock = "${nextcloud::datadir}/.puppet_update.lock" - $update_done = "${nextcloud::datadir}/.puppet_update_${nextcloud::version_normalized}.done" - $update_cmd = join([ - "touch ${update_lock}", - '&& php occ upgrade --no-interaction', - "&& touch ${update_done}", - "; rm -f ${update_lock}", # always remove lock - ], ' ') + # Commands and files required when performing an update. + $update_lock = "${nextcloud::datadir}/.puppet_update.lock" + $update_done = "${nextcloud::datadir}/.puppet_update_${nextcloud::version_normalized}.done" + $update_cmd = join([ + "touch ${update_lock}", + '&& php occ upgrade --no-interaction', + "&& touch ${update_done}", + "; rm -f ${update_lock}", # always remove lock + ], ' ') + # Only perform update tasks if this feature is enabled. + if ($nextcloud::install_enabled and $nextcloud::update_enabled =~ Boolean) { # Check if this is the designated update/install host. if (($nextcloud::update_host == undef or empty($nextcloud::update_host)) or ($nextcloud::update_host == $facts['networking']['fqdn'])) { diff --git a/spec/classes/nextcloud_spec.rb b/spec/classes/nextcloud_spec.rb index 2c1edb4..f606b47 100644 --- a/spec/classes/nextcloud_spec.rb +++ b/spec/classes/nextcloud_spec.rb @@ -28,6 +28,7 @@ it { is_expected.to contain_file('/opt/nextcloud-data').with_ensure('directory') } it { is_expected.to contain_file('Create install dir: initial install').with_ensure('directory') } + it { is_expected.to contain_archive('Extract archive: initial install') } it { is_expected.to contain_cron('Nextcloud background job').with( @@ -51,6 +52,44 @@ it { is_expected.not_to contain_nextcloud__install__distribution('initial install') } it { is_expected.not_to contain_file('Create install dir: initial install').with_ensure('directory') } + it { is_expected.not_to contain_archive('Extract archive: update to 20.0.4') } + end + context 'when install_enabled=false' do + let(:params) do + { + admin_password: 'secret', + db_password: 'secret', + install_enabled: false, + version: '20.0.4', + } + end + + it { is_expected.to compile } + + it { is_expected.not_to contain_nextcloud__install__distribution('initial install') } + it { is_expected.not_to contain_file('Create install dir: initial install').with_ensure('directory') } + + it { is_expected.not_to contain_nextcloud__install__distribution('update to 20.0.4') } + it { is_expected.not_to contain_archive('Extract archive: update to 20.0.4') } + it { is_expected.not_to contain_exec('occ upgrade') } + end + context 'when update_enabled=false' do + let(:params) do + { + admin_password: 'secret', + db_password: 'secret', + update_enabled: false, + version: '20.0.4', + } + end + + it { is_expected.to compile } + + it { is_expected.to contain_nextcloud__install__distribution('initial install') } + it { is_expected.to contain_file('Create install dir: initial install').with_ensure('directory') } + it { is_expected.to contain_nextcloud__install__distribution('update to 20.0.4') } + + it { is_expected.not_to contain_exec('occ upgrade') } end end end