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: '8', full: '8.0' } },
16 apt_update_last_success: factval,
17 lsbdistcodename: 'jessie',
20 let(:pre_condition) do
21 "class{'::apt': update => {'frequency' => 'always' },}"
24 it 'triggers an apt-get update run' do
25 # set the apt_update exec's refreshonly attribute to false
26 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
30 context 'when $::apt_update_last_success is nil' do
33 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
36 lsbdistcodename: 'jessie',
39 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
41 it 'triggers an apt-get update run' do
42 # set the apt_update exec\'s refreshonly attribute to false
43 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
47 context "when apt::update['frequency']='reluctantly'" do
49 'a recent run' => Time.now.to_i,
50 'we are due for a run' => 1_406_660_561,
51 'the update-success-stamp file does not exist' => -1,
52 }.each_pair do |desc, factval|
53 context "when $::apt_update_last_success indicates #{desc}" do
56 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
59 apt_update_last_success: factval,
60 lsbdistcodename: 'jessie',
63 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
65 it 'does not trigger an apt-get update run' do
66 # don't change the apt_update exec's refreshonly attribute. (it should be true)
67 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
71 context 'when $::apt_update_last_success is nil' do
74 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
77 lsbdistcodename: 'jessie',
80 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
82 it 'does not trigger an apt-get update run' do
83 # don't change the apt_update exec's refreshonly attribute. (it should be true)
84 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
88 ['daily', 'weekly'].each do |update_frequency|
89 context "when apt::update['frequency'] has the value of #{update_frequency}" do
90 { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
91 context "when $::apt_update_last_success indicates #{desc}" do
94 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
97 apt_update_last_success: factval,
98 lsbdistcodename: 'jessie',
101 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
103 it 'triggers an apt-get update run' do
104 # set the apt_update exec\'s refreshonly attribute to false
105 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
109 context 'when the $::apt_update_last_success fact has a recent value' do
112 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
115 lsbdistcodename: 'jessie',
116 apt_update_last_success: Time.now.to_i,
119 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
121 it 'does not trigger an apt-get update run' do
122 # don't change the apt_update exec\'s refreshonly attribute. (it should be true)
123 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
126 context 'when $::apt_update_last_success is nil' do
129 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
132 lsbdistcodename: 'jessie',
133 apt_update_last_success: nil,
136 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
138 it 'triggers an apt-get update run' do
139 # set the apt_update exec\'s refreshonly attribute to false
140 is_expected.to contain_exec('apt_update').with('refreshonly' => false)