summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorb4ldr <github@johnbond.org>2016-02-22 12:52:07 +0000
committerb4ldr <github@johnbond.org>2016-03-31 15:37:53 -0300
commit3a4abe4f98d4c24989a1def59968cb49d1d26268 (patch)
tree6908974fb30b0b99c8d70c1939511f489d43033e /spec
parent1ddfcea4c298cbe6236622020ec440e5e0633341 (diff)
add options support
fix ruby 1.9 hash correct
Diffstat (limited to 'spec')
-rw-r--r--spec/classes/unattended_upgrades_spec.rb115
1 files changed, 115 insertions, 0 deletions
diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb
index d951a87..7bc7365 100644
--- a/spec/classes/unattended_upgrades_spec.rb
+++ b/spec/classes/unattended_upgrades_spec.rb
@@ -3,6 +3,7 @@ require 'spec_helper'
describe 'unattended_upgrades' do
let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' }
let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' }
+ let(:file_options) { '/etc/apt/apt.conf.d/10options' }
let(:facts) { {
osfamily: 'Debian',
lsbdistid: 'Debian',
@@ -31,6 +32,13 @@ describe 'unattended_upgrades' do
}
it {
+ should contain_apt__conf('options').with(
+ require: 'Package[unattended-upgrades]',
+ notify_update: false,
+ )
+ }
+
+ it {
should create_file(file_unattended).with(
owner: 'root',
group: 'root',
@@ -96,6 +104,23 @@ describe 'unattended_upgrades' do
ensure: 'absent',
)
}
+ it {
+ should create_file(file_options).with(
+ owner: 'root',
+ group: 'root',
+ mode: '0644',
+ ).with_content(
+ /^Dpkg::Options\s{/
+ ).with_content(
+ /^\s+\"--force-confdef\";/
+ ).with_content(
+ /^\s+\"--force-confold\";/
+ ).without_content(
+ /\"--force-confnew\";/
+ ).without_content(
+ /\"--force-confmiss\";/
+ )
+ }
end
context 'with defaults on Debian 6 Squeeze' do
@@ -295,6 +320,12 @@ describe 'unattended_upgrades' do
dl_limit: 70,
random_sleep: 300,
notify_update: true,
+ options: {
+ 'force_confdef' => false,
+ 'force_confold' => false,
+ 'force_confnew' => true,
+ 'force_confmiss' => true,
+ }
}
end
it { should contain_package('unattended-upgrades') }
@@ -312,6 +343,13 @@ describe 'unattended_upgrades' do
}
it {
+ should contain_apt__conf('options').with(
+ require: 'Package[unattended-upgrades]',
+ notify_update: true,
+ )
+ }
+
+ it {
should create_file(file_unattended).with(
owner: 'root',
group: 'root',
@@ -376,6 +414,23 @@ describe 'unattended_upgrades' do
}
it {
+ should create_file(file_options).with(
+ owner: 'root',
+ group: 'root',
+ mode: '0644',
+ ).with_content(
+ /^Dpkg::Options\s{/
+ ).without_content(
+ /"--force-confdef";/
+ ).without_content(
+ /"--force-confold";/
+ ).with_content(
+ /^\s+"--force-confnew";/
+ ).with_content(
+ /^\s+"--force-confmiss";/
+ )
+ }
+ it {
should contain_apt__conf('auto-upgrades').with(
ensure: 'absent',
)
@@ -527,5 +582,65 @@ describe 'unattended_upgrades' do
}.to raise_error(Puppet::Error, /not a boolean/)
end
end
+ context 'bad options[\'force_confdef\']' do
+ let :params do
+ {
+ options: { 'force_confdef' => 'foo' },
+ }
+ end
+ it do
+ expect {
+ subject.call
+ }.to raise_error(Puppet::Error, /not a boolean/)
+ end
+ end
+ context 'bad options[\'force_confold\']' do
+ let :params do
+ {
+ options: { 'force_confold' => 'foo' },
+ }
+ end
+ it do
+ expect {
+ subject.call
+ }.to raise_error(Puppet::Error, /not a boolean/)
+ end
+ end
+ context 'bad options[\'force_confnew\']' do
+ let :params do
+ {
+ options: { 'force_confnew' => 'foo' },
+ }
+ end
+ it do
+ expect {
+ subject.call
+ }.to raise_error(Puppet::Error, /not a boolean/)
+ end
+ end
+ context 'bad options[\'force_confmiss\']' do
+ let :params do
+ {
+ options: { 'force_confmiss' => 'foo' },
+ }
+ end
+ it do
+ expect {
+ subject.call
+ }.to raise_error(Puppet::Error, /not a boolean/)
+ end
+ end
+ context 'bad options[\'invalid_key\']' do
+ let :params do
+ {
+ options: { 'invalid_key' => true },
+ }
+ end
+ it do
+ expect {
+ subject.call
+ }.to raise_error(Puppet::Error, /invalid_key not a valid key/)
+ end
+ end
end
end