3 describe 'apt::update', type: :class do
4 context "when apt::update['frequency']='always'" do
6 'a recent run' => Time.now.to_i,
7 'we are due for a run' => 1_406_660_561,
8 'the update-success-stamp file does not exist' => -1,
9 }.each_pair do |desc, factval|
10 context "when $::apt_update_last_success indicates #{desc}" do
13 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
16 apt_update_last_success: factval,
17 lsbdistcodename: 'wheezy',
18 puppetversion: Puppet.version,
21 let(:pre_condition) do
22 "class{'::apt': update => {'frequency' => 'always' },}"
25 it 'triggers an apt-get update run' do
26 # set the apt_update exec's refreshonly attribute to false
27 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
31 context 'when $::apt_update_last_success is nil' do
34 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
37 lsbdistcodename: 'wheezy',
38 puppetversion: Puppet.version,
41 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
43 it 'triggers an apt-get update run' do
44 # set the apt_update exec\'s refreshonly attribute to false
45 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
49 context "when apt::update['frequency']='reluctantly'" do
51 'a recent run' => Time.now.to_i,
52 'we are due for a run' => 1_406_660_561,
53 'the update-success-stamp file does not exist' => -1,
54 }.each_pair do |desc, factval|
55 context "when $::apt_update_last_success indicates #{desc}" do
58 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
61 apt_update_last_success: factval,
62 lsbdistcodename: 'wheezy',
63 puppetversion: Puppet.version,
66 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
68 it 'does not trigger an apt-get update run' do
69 # don't change the apt_update exec's refreshonly attribute. (it should be true)
70 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
74 context 'when $::apt_update_last_success is nil' do
77 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
80 lsbdistcodename: 'wheezy',
81 puppetversion: Puppet.version,
84 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
86 it 'does not trigger an apt-get update run' do
87 # don't change the apt_update exec's refreshonly attribute. (it should be true)
88 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
92 ['daily', 'weekly'].each do |update_frequency|
93 context "when apt::update['frequency'] has the value of #{update_frequency}" do
94 { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
95 context "when $::apt_update_last_success indicates #{desc}" do
98 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
101 apt_update_last_success: factval,
102 lsbdistcodename: 'wheezy',
103 puppetversion: Puppet.version,
106 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
108 it 'triggers an apt-get update run' do
109 # set the apt_update exec\'s refreshonly attribute to false
110 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
114 context 'when the $::apt_update_last_success fact has a recent value' do
117 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
120 lsbdistcodename: 'wheezy',
121 apt_update_last_success: Time.now.to_i,
122 puppetversion: Puppet.version,
125 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
127 it 'does not trigger an apt-get update run' do
128 # don't change the apt_update exec\'s refreshonly attribute. (it should be true)
129 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
132 context 'when $::apt_update_last_success is nil' do
135 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
138 lsbdistcodename: 'wheezy',
139 apt_update_last_success: nil,
140 puppetversion: Puppet.version,
143 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
145 it 'triggers an apt-get update run' do
146 # set the apt_update exec\'s refreshonly attribute to false
147 is_expected.to contain_exec('apt_update').with('refreshonly' => false)