Merge pull request #516 from dlactin/feature/master/apt_reboot_required_fact

Added new apt_reboot_required fact, updated readme, and added unit tests
This commit is contained in:
Morgan Haskel 2015-04-29 15:34:43 -07:00
commit 96d48eca08
3 changed files with 32 additions and 0 deletions

View file

@ -217,6 +217,8 @@ apt::sources:
* `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run (based on the mtime of /var/lib/apt/periodic/update-success-stamp).
* `apt_reboot_required`: Determines if a reboot is necessary after updates have been installed.
#### Class: `apt`
Main class, includes all other classes.

View file

@ -0,0 +1,7 @@
# apt_reboot_required.rb
Facter.add(:apt_reboot_required) do
confine :osfamily => 'Debian'
setcode do
File.file?('/var/run/reboot-required')
end
end

View file

@ -0,0 +1,23 @@
require 'spec_helper'
describe 'apt_reboot_required fact' do
subject { Facter.fact(:apt_reboot_required).value }
after(:each) { Facter.clear }
describe 'if a reboot is required' do
before {
Facter.fact(:osfamily).stubs(:value).returns 'Debian'
File.stubs(:file?).returns true
}
it { expect(Facter.fact(:apt_reboot_required).value).to eq true }
end
describe 'if a reboot is not required' do
before {
Facter.fact(:osfamily).stubs(:value).returns 'Debian'
File.stubs(:file?).returns false
}
it { expect(Facter.fact(:apt_reboot_required).value).to eq false }
end
end