4 describe 'apt::update', :type => :class do
5 context "and apt::update['frequency']='always'" do
7 'a recent run' => Time.now.to_i,
8 'we are due for a run' => 1406660561,
9 'the update-success-stamp file does not exist' => -1,
10 }.each_pair do |desc, factval|
11 context "and $::apt_update_last_success indicates #{desc}" do
13 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
14 :lsbdistid => 'Debian',
15 :osfamily => 'Debian',
16 :apt_update_last_success => factval,
17 :lsbdistcodename => 'wheezy',
18 :puppetversion => Puppet.version,
20 let (:pre_condition) {
21 "class{'::apt': update => {'frequency' => 'always' },}"
23 it 'should trigger an apt-get update run' do
24 #set the apt_update exec's refreshonly attribute to false
25 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
29 context 'when $::apt_update_last_success is nil' do
31 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
32 :lsbdistid => 'Debian',
33 :osfamily => 'Debian',
34 :lsbdistcodename => 'wheezy',
35 :puppetversion => Puppet.version,
37 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
38 it 'should trigger an apt-get update run' do
39 #set the apt_update exec\'s refreshonly attribute to false
40 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
44 context "and apt::update['frequency']='reluctantly'" do
46 'a recent run' => Time.now.to_i,
47 'we are due for a run' => 1406660561,
48 'the update-success-stamp file does not exist' => -1,
49 }.each_pair do |desc, factval|
50 context "and $::apt_update_last_success indicates #{desc}" do
52 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
53 :lsbdistid => 'Debian',
54 :osfamily => 'Debian',
55 :apt_update_last_success => factval,
56 :lsbdistcodename => 'wheezy',
57 :puppetversion => Puppet.version,
59 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
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})
66 context 'when $::apt_update_last_success is nil' do
68 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
69 :lsbdistid => 'Debian',
70 :osfamily => 'Debian',
71 :lsbdistcodename => 'wheezy',
72 :puppetversion => Puppet.version,
74 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
75 it 'should not trigger an apt-get update run' do
76 #don't change the apt_update exec's refreshonly attribute. (it should be true)
77 is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
81 ['daily','weekly'].each do |update_frequency|
82 context "and apt::update['frequency'] has the value of #{update_frequency}" do
83 { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
84 context "and $::apt_update_last_success indicates #{desc}" do
86 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
87 :lsbdistid => 'Debian',
88 :osfamily => 'Debian',
89 :apt_update_last_success => factval,
90 :lsbdistcodename => 'wheezy',
91 :puppetversion => Puppet.version,
93 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
94 it 'should trigger an apt-get update run' do
95 #set the apt_update exec\'s refreshonly attribute to false
96 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
100 context 'when the $::apt_update_last_success fact has a recent value' do
102 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
103 :lsbdistid => 'Debian',
104 :osfamily => 'Debian',
105 :lsbdistcodename => 'wheezy',
106 :apt_update_last_success => Time.now.to_i,
107 :puppetversion => Puppet.version,
109 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
110 it 'should not trigger an apt-get update run' do
111 #don't change the apt_update exec\'s refreshonly attribute. (it should be true)
112 is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
115 context 'when $::apt_update_last_success is nil' do
117 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
118 :lsbdistid => 'Debian',
119 :osfamily => 'Debian',
120 :lsbdistcodename => 'wheezy',
121 :apt_update_last_success => nil,
122 :puppetversion => Puppet.version,
124 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
125 it 'should trigger an apt-get update run' do
126 #set the apt_update exec\'s refreshonly attribute to false
127 is_expected.to contain_exec('apt_update').with({'refreshonly' => false})