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' => 1_406_660_561,
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
14 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
17 apt_update_last_success: factval,
18 lsbdistcodename: 'wheezy',
19 puppetversion: Puppet.version,
22 let (:pre_condition) do
23 "class{'::apt': update => {'frequency' => 'always' },}"
26 it 'triggers an apt-get update run' do
27 # set the apt_update exec's refreshonly attribute to false
28 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
32 context 'when $::apt_update_last_success is nil' do
35 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
38 lsbdistcodename: 'wheezy',
39 puppetversion: Puppet.version,
42 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
44 it 'triggers an apt-get update run' do
45 # set the apt_update exec\'s refreshonly attribute to false
46 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
50 context "and apt::update['frequency']='reluctantly'" do
52 'a recent run' => Time.now.to_i,
53 'we are due for a run' => 1_406_660_561,
54 'the update-success-stamp file does not exist' => -1,
55 }.each_pair do |desc, factval|
56 context "and $::apt_update_last_success indicates #{desc}" do
59 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
62 apt_update_last_success: factval,
63 lsbdistcodename: 'wheezy',
64 puppetversion: Puppet.version,
67 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
69 it 'does not trigger an apt-get update run' do
70 # don't change the apt_update exec's refreshonly attribute. (it should be true)
71 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
75 context 'when $::apt_update_last_success is nil' do
78 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
81 lsbdistcodename: 'wheezy',
82 puppetversion: Puppet.version,
85 let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
87 it 'does not trigger an apt-get update run' do
88 # don't change the apt_update exec's refreshonly attribute. (it should be true)
89 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
93 %w[daily weekly].each do |update_frequency|
94 context "and apt::update['frequency'] has the value of #{update_frequency}" do
95 { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
96 context "and $::apt_update_last_success indicates #{desc}" do
99 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
102 apt_update_last_success: factval,
103 lsbdistcodename: 'wheezy',
104 puppetversion: Puppet.version,
107 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
109 it 'triggers an apt-get update run' do
110 # set the apt_update exec\'s refreshonly attribute to false
111 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
115 context 'when the $::apt_update_last_success fact has a recent value' do
118 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
121 lsbdistcodename: 'wheezy',
122 apt_update_last_success: Time.now.to_i,
123 puppetversion: Puppet.version,
126 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
128 it 'does not trigger an apt-get update run' do
129 # don't change the apt_update exec\'s refreshonly attribute. (it should be true)
130 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
133 context 'when $::apt_update_last_success is nil' do
136 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
139 lsbdistcodename: 'wheezy',
140 apt_update_last_success: nil,
141 puppetversion: Puppet.version,
144 let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
146 it 'triggers an apt-get update run' do
147 # set the apt_update exec\'s refreshonly attribute to false
148 is_expected.to contain_exec('apt_update').with('refreshonly' => false)