4 describe 'apt::update', :type => :class do
5 context "and apt::update['frequency']='always'" do
6 { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
7 context "and $::apt_update_last_success indicates #{desc}" do
8 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
9 let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" }
10 it 'should trigger an apt-get update run' do
11 #set the apt_update exec's refreshonly attribute to false
12 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
16 context 'when $::apt_update_last_success is nil' do
17 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
18 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
19 it 'should trigger an apt-get update run' do
20 #set the apt_update exec\'s refreshonly attribute to false
21 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
25 context "and apt::update['frequency']='reluctantly'" do
26 {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
27 context "and $::apt_update_last_success indicates #{desc}" do
28 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version,} }
29 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
30 it 'should not trigger an apt-get update run' do
31 #don't change the apt_update exec's refreshonly attribute. (it should be true)
32 is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
36 context 'when $::apt_update_last_success is nil' do
37 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
38 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
39 it 'should not trigger an apt-get update run' do
40 #don't change the apt_update exec's refreshonly attribute. (it should be true)
41 is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
45 ['daily','weekly'].each do |update_frequency|
46 context "and apt::update['frequency'] has the value of #{update_frequency}" do
47 { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
48 context "and $::apt_update_last_success indicates #{desc}" do
49 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
50 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
51 it 'should trigger an apt-get update run' do
52 #set the apt_update exec\'s refreshonly attribute to false
53 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
57 context 'when the $::apt_update_last_success fact has a recent value' do
58 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i, :puppetversion => Puppet.version, } }
59 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
60 it 'should not trigger an apt-get update run' do
61 #don't change the apt_update exec\'s refreshonly attribute. (it should be true)
62 is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
65 context 'when $::apt_update_last_success is nil' do
66 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil, :puppetversion => Puppet.version, } }
67 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
68 it 'should trigger an apt-get update run' do
69 #set the apt_update exec\'s refreshonly attribute to false
70 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})