Skip to content

Commit

Permalink
apt::setting: Dont expect source/content when removing settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Nov 21, 2024
1 parent a213640 commit db4d4fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions manifests/setting.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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, '-')
Expand Down
9 changes: 8 additions & 1 deletion spec/defines/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down

0 comments on commit db4d4fb

Please sign in to comment.