(maint) Confine lsbdistdescription to depend on lsb_release
Adrien Thebo
10 years ago
11 | 11 |
|
12 | 12 |
Facter.add(:lsbdistdescription) do
|
13 | 13 |
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
|
14 |
confine do
|
|
15 |
Facter::Core::Execution.which("lsb_release")
|
|
16 |
end
|
|
17 |
|
14 | 18 |
setcode do
|
15 | 19 |
if output = Facter::Core::Execution.exec('lsb_release -d -s 2>/dev/null')
|
16 | 20 |
# the output may be quoted (at least it is on gentoo)
|
9 | 9 |
Facter.fact(:kernel).stubs(:value).returns kernel
|
10 | 10 |
end
|
11 | 11 |
|
12 | |
it "should return the description through lsb_release -d -s 2>/dev/null" do
|
13 | |
Facter::Core::Execution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns '"Gentoo Base System release 2.1"'
|
14 | |
Facter.fact(:lsbdistdescription).value.should == 'Gentoo Base System release 2.1'
|
|
12 |
it "returns the description through lsb_release -d -s 2>/dev/null" do
|
|
13 |
Facter::Core::Execution.impl.stubs(:exec).with('lsb_release -d -s 2>/dev/null', anything).returns '"Gentoo Base System release 2.1"'
|
|
14 |
expect(Facter.fact(:lsbdistdescription).value).to eq 'Gentoo Base System release 2.1'
|
15 | 15 |
end
|
16 | 16 |
|
17 | |
it "should return nil if lsb_release is not installed" do
|
18 | |
Facter::Core::Execution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns nil
|
19 | |
Facter.fact(:lsbdistdescription).value.should be_nil
|
|
17 |
it "returns nil if lsb_release is not installed" do
|
|
18 |
Facter::Core::Execution.stubs(:which).with('lsb_release').returns nil
|
|
19 |
expect(Facter.fact(:lsbdistdescription).value).to be_nil
|
20 | 20 |
end
|
21 | 21 |
end
|
22 | 22 |
end
|
23 | |
|
24 | 23 |
end
|