forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #476 from jonnytpuppet/fix_recent_os
Fix recent os
- Loading branch information
Showing
5 changed files
with
123 additions
and
32 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
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
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
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
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 |
---|---|---|
@@ -1,35 +1,100 @@ | ||
require 'spec_helper' | ||
|
||
describe "Facter::Util::Fact iptables_persistent_version" do | ||
before { Facter.clear } | ||
let(:dpkg_cmd) { "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" } | ||
|
||
{ | ||
"Debian" => "0.0.20090701", | ||
"Ubuntu" => "0.5.3ubuntu2", | ||
}.each do |os, ver| | ||
describe "#{os} package installed" do | ||
|
||
|
||
context "iptables-persistent applicable" do | ||
before { Facter.clear } | ||
|
||
let(:dpkg_cmd) { "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" } | ||
|
||
{ | ||
"Debian" => "0.0.20090701", | ||
"Ubuntu" => "0.5.3ubuntu2", | ||
}.each do |os, ver| | ||
|
||
if os == "Debian" | ||
os_release = "7.0" | ||
elsif os == "Ubuntu" | ||
os_release = "14.04" | ||
end | ||
|
||
describe "#{os} package installed" do | ||
before { | ||
allow(Facter.fact(:operatingsystem)).to receive(:value).and_return(os) | ||
allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return(os_release) | ||
allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd). | ||
and_return(ver) | ||
} | ||
it { Facter.fact(:iptables_persistent_version).value.should == ver } | ||
end | ||
end | ||
|
||
describe 'Ubuntu package not installed' do | ||
before { | ||
allow(Facter.fact(:operatingsystem)).to receive(:value).and_return(os) | ||
allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Ubuntu') | ||
allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return('14.04') | ||
allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd). | ||
and_return(ver) | ||
and_return(nil) | ||
} | ||
it { Facter.fact(:iptables_persistent_version).value.should == ver } | ||
it { Facter.fact(:iptables_persistent_version).value.should be_nil } | ||
end | ||
|
||
describe 'CentOS not supported' do | ||
before { allow(Facter.fact(:operatingsystem)).to receive(:value). | ||
and_return("CentOS") } | ||
it { Facter.fact(:iptables_persistent_version).value.should be_nil } | ||
end | ||
end | ||
|
||
describe 'Ubuntu package not installed' do | ||
before { | ||
allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Ubuntu') | ||
allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd). | ||
and_return(nil) | ||
} | ||
it { Facter.fact(:iptables_persistent_version).value.should be_nil } | ||
end | ||
|
||
describe 'CentOS not supported' do | ||
before { allow(Facter.fact(:operatingsystem)).to receive(:value). | ||
and_return("CentOS") } | ||
it { Facter.fact(:iptables_persistent_version).value.should be_nil } | ||
context "netfilter-persistent applicable" do | ||
before { Facter.clear } | ||
|
||
let(:dpkg_cmd) { "dpkg-query -Wf '${Version}' netfilter-persistent 2>/dev/null" } | ||
|
||
{ | ||
"Debian" => "0.0.20090701", | ||
"Ubuntu" => "0.5.3ubuntu2", | ||
}.each do |os, ver| | ||
|
||
if os == "Debian" | ||
os_release = "8.0" | ||
elsif os == "Ubuntu" | ||
os_release = "14.10" | ||
end | ||
|
||
describe "#{os} package installed" do | ||
before { | ||
allow(Facter.fact(:operatingsystem)).to receive(:value).and_return(os) | ||
allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return(os_release) | ||
allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd). | ||
and_return(ver) | ||
} | ||
it { Facter.fact(:iptables_persistent_version).value.should == ver } | ||
end | ||
end | ||
|
||
describe 'Ubuntu package not installed' do | ||
os_release = "14.10" | ||
before { | ||
allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Ubuntu') | ||
allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return(os_release) | ||
allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd). | ||
and_return(nil) | ||
} | ||
it { Facter.fact(:iptables_persistent_version).value.should be_nil } | ||
end | ||
|
||
describe 'CentOS not supported' do | ||
before { allow(Facter.fact(:operatingsystem)).to receive(:value). | ||
and_return("CentOS") } | ||
it { Facter.fact(:iptables_persistent_version).value.should be_nil } | ||
end | ||
|
||
end | ||
|
||
|
||
|
||
|
||
end |