Skip to content

Commit

Permalink
add smartd fact
Browse files Browse the repository at this point in the history
Fact for the path to the smartd executable.
  • Loading branch information
Joshua Hoblitt committed Apr 11, 2014
1 parent 0950ccb commit 8cbfc2b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/facter/smartd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Facter.add(:smartd) do
confine :kernel => :linux

setcode do
Facter::Util::Resolution.which('smartd')
end
end
25 changes: 25 additions & 0 deletions spec/unit/facts/smartd_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

describe 'smartd', :type => :fact do
before(:each) { Facter.clear }

context 'on linux' do
context 'not in path' do
it do
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter::Util::Resolution.stubs(:which).with('smartd').returns(nil)
Facter.fact(:smartd).value.should be_nil
end
end

context 'in path' do
it do
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter::Util::Resolution.stubs(:which).with('smartd').returns('/usr/sbin/smartd')
Facter.fact(:smartd).value.should == '/usr/sbin/smartd'
end
end
end

end

0 comments on commit 8cbfc2b

Please sign in to comment.