From db4d4fbca870df89275c3bc2990a5d1d6041c067 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 21 Nov 2024 14:45:49 +0100 Subject: [PATCH] apt::setting: Dont expect source/content when removing settings --- manifests/setting.pp | 6 ++++-- spec/defines/setting_spec.rb | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/manifests/setting.pp b/manifests/setting.pp index 3dd14cdff2..46b347d96a 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -30,8 +30,10 @@ fail('apt::setting cannot have both content and source') } - if !$content and !$source { - fail('apt::setting needs either of content or source') + if $ensure != 'absent' { + if !$content and !$source { + fail('apt::setting needs either of content or source') + } } $title_array = split($title, '-') diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 7a71896053..58bdf75b37 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -143,9 +143,16 @@ it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') } end - describe 'with ensure=absent' do + describe 'with ensure=absent and default params' do let(:params) { default_params.merge(ensure: 'absent') } + it { + expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent') + } + end + describe 'with ensure=absent and without default params' do + let(:params) { { ensure: 'absent' } } + it { expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent') }