2014-08-18 22:12:55 +02:00
|
|
|
#!/usr/bin/env rspec
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'apt::update', :type => :class do
|
2015-03-18 21:52:12 +01:00
|
|
|
context "and apt::update['frequency']='always'" do
|
|
|
|
{ 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
|
|
|
|
context "and $::apt_update_last_success indicates #{desc}" do
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
|
2015-03-18 21:52:12 +01:00
|
|
|
let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" }
|
2014-08-18 22:12:55 +02:00
|
|
|
it 'should trigger an apt-get update run' do
|
2015-03-18 21:52:12 +01:00
|
|
|
#set the apt_update exec's refreshonly attribute to false
|
2015-02-24 22:20:29 +01:00
|
|
|
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
|
2014-08-18 22:12:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-03-18 21:52:12 +01:00
|
|
|
context 'when $::apt_update_last_success is nil' do
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
|
2015-03-18 21:52:12 +01:00
|
|
|
let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
|
|
|
|
it 'should trigger an apt-get update run' do
|
|
|
|
#set the apt_update exec\'s refreshonly attribute to false
|
|
|
|
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
|
2014-08-18 22:12:55 +02:00
|
|
|
end
|
2015-03-18 21:52:12 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
context "and apt::update['frequency']='reluctantly'" do
|
|
|
|
{'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
|
|
|
|
context "and $::apt_update_last_success indicates #{desc}" do
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version,} }
|
2015-03-18 21:52:12 +01:00
|
|
|
let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
|
2014-08-18 22:12:55 +02:00
|
|
|
it 'should not trigger an apt-get update run' do
|
|
|
|
#don't change the apt_update exec's refreshonly attribute. (it should be true)
|
2015-02-24 22:20:29 +01:00
|
|
|
is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
|
2014-08-18 22:12:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-03-18 21:52:12 +01:00
|
|
|
context 'when $::apt_update_last_success is nil' do
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
|
2015-03-18 21:52:12 +01:00
|
|
|
let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
|
|
|
|
it 'should not trigger an apt-get update run' do
|
|
|
|
#don't change the apt_update exec's refreshonly attribute. (it should be true)
|
|
|
|
is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
['daily','weekly'].each do |update_frequency|
|
|
|
|
context "and apt::update['frequency'] has the value of #{update_frequency}" do
|
|
|
|
{ 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
|
|
|
|
context "and $::apt_update_last_success indicates #{desc}" do
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
|
2015-03-18 21:52:12 +01:00
|
|
|
let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
|
2014-08-18 22:12:55 +02:00
|
|
|
it 'should trigger an apt-get update run' do
|
|
|
|
#set the apt_update exec\'s refreshonly attribute to false
|
2015-02-24 22:20:29 +01:00
|
|
|
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
|
2014-08-18 22:12:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-03-18 21:52:12 +01:00
|
|
|
context 'when the $::apt_update_last_success fact has a recent value' do
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i, :puppetversion => Puppet.version, } }
|
2015-03-18 21:52:12 +01:00
|
|
|
let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
|
|
|
|
it 'should not trigger an apt-get update run' do
|
|
|
|
#don't change the apt_update exec\'s refreshonly attribute. (it should be true)
|
|
|
|
is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when $::apt_update_last_success is nil' do
|
2015-05-07 00:10:05 +02:00
|
|
|
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil, :puppetversion => Puppet.version, } }
|
2015-03-18 21:52:12 +01:00
|
|
|
let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
|
|
|
|
it 'should trigger an apt-get update run' do
|
|
|
|
#set the apt_update exec\'s refreshonly attribute to false
|
|
|
|
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
|
|
|
|
end
|
|
|
|
end
|
2014-08-18 22:12:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|