Skip to content

Commit

Permalink
Added new apt_reboot_required fact, updated readme, and added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dlactin committed Apr 29, 2015
1 parent 55a17ac commit 6e51be7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -443,4 +445,4 @@ Puppet Labs modules on the Puppet Forge are open projects, and community contrib

For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html)

To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors)
To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors)
7 changes: 7 additions & 0 deletions lib/facter/apt_reboot_required.rb
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions spec/unit/facter/apt_reboot_required_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6e51be7

Please sign in to comment.