X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fclasses%2Fapt_update_spec.rb;h=ada31b160060b30742cc661d398191545d446027;hb=945062184700d344111871c7cd7ac768842d253e;hp=b3d1df545bf942b0eb3f8c57f466ac0f3db43cf4;hpb=65e03244552e8113b69f6ca5f4e6dc142251df0b;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index b3d1df5..ada31b1 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe 'apt::update', type: :class do context "when apt::update['frequency']='always'" do { - 'a recent run' => Time.now.to_i, - 'we are due for a run' => 1_406_660_561, - 'the update-success-stamp file does not exist' => -1, + 'a recent run' => Time.now.to_i, + 'we are due for a run' => 1_406_660_561, + 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do let(:facts) do @@ -17,14 +17,14 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - 'apt::apt_update_last_success': factval, + apt_update_last_success: factval } end let(:pre_condition) do @@ -33,7 +33,7 @@ describe 'apt::update', type: :class do it 'triggers 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) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end end @@ -45,22 +45,23 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } it 'triggers 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) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end + context 'and Exec[apt_update] refreshonly is overridden to true and has recent run' do let(:facts) do { @@ -69,14 +70,14 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - 'apt::apt_update_last_success': Time.now.to_i, + apt_update_last_success: Time.now.to_i } end let(:pre_condition) do @@ -88,15 +89,16 @@ describe 'apt::update', type: :class do it 'skips 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' => true) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end end + context "when apt::update['frequency']='reluctantly'" do { - 'a recent run' => Time.now.to_i, - 'we are due for a run' => 1_406_660_561, - 'the update-success-stamp file does not exist' => -1, + 'a recent run' => Time.now.to_i, + 'we are due for a run' => 1_406_660_561, + 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do let(:facts) do @@ -106,21 +108,21 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - 'apt::apt_update_last_success': factval, + apt_update_last_success: factval } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'does 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) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end end @@ -132,23 +134,24 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'does 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) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end end + ['daily', 'weekly'].each do |update_frequency| context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| @@ -160,21 +163,21 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - 'apt::apt_update_last_success': factval, + apt_update_last_success: factval } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'triggers 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) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end end @@ -186,23 +189,24 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - 'apt::apt_update_last_success': Time.now.to_i, + apt_update_last_success: Time.now.to_i } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'does 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) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end + context 'when $apt_update_last_success is nil' do let(:facts) do { @@ -211,21 +215,21 @@ describe 'apt::update', type: :class do name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - 'apt::apt_update_last_success': nil, + apt_update_last_success: nil } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'triggers 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) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end end