Skip to content

Commit

Permalink
apt::conf: Don't require content ensure=>absent.
Browse files Browse the repository at this point in the history
  • Loading branch information
daenney committed Apr 14, 2015
1 parent 02e1e05 commit fe60980
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 8 additions & 1 deletion manifests/conf.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
define apt::conf (
$content,
$content = undef,
$ensure = present,
$priority = '50',
) {

unless $ensure == 'absent' {
unless $content {
fail('Need to pass in content parameter')
}
}

apt::setting { "conf-${name}":
ensure => $ensure,
priority => $priority,
Expand Down
14 changes: 12 additions & 2 deletions spec/defines/conf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,23 @@
}
end

describe "when creating a preference without content" do
let :params do
{
:priority => '00',
}
end

it 'fails' do
expect { subject } .to raise_error(/pass in content/)
end
end

describe "when removing an apt preference" do
let :params do
{
:ensure => 'absent',
:priority => '00',
:content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
}
end

Expand All @@ -45,7 +56,6 @@

it { is_expected.to contain_file(filename).with({
'ensure' => 'absent',
'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/,
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
Expand Down

0 comments on commit fe60980

Please sign in to comment.