1 # frozen_string_literal: true
5 describe 'apt::update', type: :class do
6 context "when apt::update['frequency']='always'" do
8 'a recent run' => Time.now.to_i,
9 'we are due for a run' => 1_406_660_561,
10 'the update-success-stamp file does not exist' => -1,
11 }.each_pair do |desc, factval|
12 context "when $::apt_update_last_success indicates #{desc}" do
27 apt_update_last_success: factval,
30 let(:pre_condition) do
31 "class{'::apt': update => {'frequency' => 'always' },}"
34 it 'triggers an apt-get update run' do
35 # set the apt_update exec's refreshonly attribute to false
36 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
40 context 'when $::apt_update_last_success is nil' do
57 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
59 it 'triggers an apt-get update run' do
60 # set the apt_update exec\'s refreshonly attribute to false
61 is_expected.to contain_exec('apt_update').with('refreshonly' => false)
65 context "when apt::update['frequency']='reluctantly'" do
67 'a recent run' => Time.now.to_i,
68 'we are due for a run' => 1_406_660_561,
69 'the update-success-stamp file does not exist' => -1,
70 }.each_pair do |desc, factval|
71 context "when $::apt_update_last_success indicates #{desc}" do
86 apt_update_last_success: factval,
89 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
91 it 'does not trigger an apt-get update run' do
92 # don't change the apt_update exec's refreshonly attribute. (it should be true)
93 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
97 context 'when $::apt_update_last_success is nil' do
114 let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
116 it 'does not trigger an apt-get update run' do
117 # don't change the apt_update exec's refreshonly attribute. (it should be true)
118 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
122 ['daily', 'weekly'].each do |update_frequency|
123 context "when apt::update['frequency'] has the value of #{update_frequency}" do
124 { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
125 context "when $::apt_update_last_success indicates #{desc}" do
140 apt_update_last_success: factval,
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)
151 context 'when the $::apt_update_last_success fact has a recent value' do
166 apt_update_last_success: Time.now.to_i,
169 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
171 it 'does not trigger an apt-get update run' do
172 # don't change the apt_update exec\'s refreshonly attribute. (it should be true)
173 is_expected.to contain_exec('apt_update').with('refreshonly' => true)
176 context 'when $::apt_update_last_success is nil' do
191 apt_update_last_success: nil,
194 let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
196 it 'triggers an apt-get update run' do
197 # set the apt_update exec\'s refreshonly attribute to false
198 is_expected.to contain_exec('apt_update').with('refreshonly' => false)