-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Hoblitt
committed
Nov 8, 2013
1 parent
4675af2
commit 172ae55
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Facter.add('mdadmversion') do | ||
mdadm = Facter.value(:mdadm) | ||
setcode do | ||
unless mdadm.nil? | ||
# `mdadm --version` sends it's output to stderr | ||
Facter::Util::Resolution.exec("#{mdadm} --version 2>&1") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe 'mdadmversion', :type => :fact do | ||
before(:each) { Facter.clear } | ||
|
||
context 'mdadm fact => /sbin/madam' do | ||
it 'should get the version string' do | ||
Facter.fact(:mdadm).stubs(:value).returns('/sbin/mdadm') | ||
Facter::Util::Resolution.stubs(:exec).with('/sbin/mdadm --version 2>&1').returns('mdadm - v3.2.3 - 23rd December 2011') | ||
|
||
Facter.fact(:mdadmversion).value.should == 'mdadm - v3.2.3 - 23rd December 2011' | ||
end | ||
end | ||
|
||
context 'mdadm fact not set' do | ||
it 'should return nil' do | ||
Facter.fact(:mdadm).stubs(:value).returns(nil) | ||
Facter.fact(:mdadmversion).value.should be_nil | ||
end | ||
end | ||
end |