Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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