From 1125e1e050a3807df2ada4d8cf2d36c22a75ed2b Mon Sep 17 00:00:00 2001 From: Hans de Graaff Date: Sat, 18 Sep 2010 17:31:11 +0200 Subject: Make sure FreeBSD spec also works on systems that have /proc/cpuinfo. --- spec/unit/util/virtual.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb index 1e31a2f..cc528d1 100644 --- a/spec/unit/util/virtual.rb +++ b/spec/unit/util/virtual.rb @@ -101,6 +101,7 @@ describe Facter::Util::Virtual do end it "should detect kvm on FreeBSD" do + FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false) Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns("QEMU Virtual CPU version 0.12.4") Facter::Util::Virtual.should be_kvm -- cgit From d62b01394888c0aefa87aa10f51d3bf21363300d Mon Sep 17 00:00:00 2001 From: Paul Nasrat Date: Thu, 7 Oct 2010 09:12:28 -0700 Subject: Issue #4889 Fact values should all be strings Fix is_virtual fact to return strings rather than bools. --- lib/facter/virtual.rb | 4 ++-- spec/unit/virtual.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index c14a715..af530e5 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -81,9 +81,9 @@ Facter.add("is_virtual") do setcode do case Facter.value(:virtual) when "xenu", "openvzve", "vmware", "kvm", "vserver", "jail" - true + "true" else - false + "false" end end end diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb index 8ee843b..80cd0d9 100644 --- a/spec/unit/virtual.rb +++ b/spec/unit/virtual.rb @@ -35,37 +35,37 @@ describe "is_virtual fact" do it "should be virtual when running on xen" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("xenu") - Facter.fact(:is_virtual).value.should == true + Facter.fact(:is_virtual).value.should == "true" end it "should be false when running on xen0" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("xen0") - Facter.fact(:is_virtual).value.should == false + Facter.fact(:is_virtual).value.should == "false" end it "should be true when running on vmware" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("vmware") - Facter.fact(:is_virtual).value.should == true + Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on openvz" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("openvzve") - Facter.fact(:is_virtual).value.should == true + Facter.fact(:is_virtual).value.should == "true" end it "should be true when running on kvm" do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:virtual).stubs(:value).returns("kvm") - Facter.fact(:is_virtual).value.should == true + Facter.fact(:is_virtual).value.should == "true" end it "should be true when running in jail" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter.fact(:virtual).stubs(:value).returns("jail") - Facter.fact(:is_virtual).value.should == true + Facter.fact(:is_virtual).value.should == "true" end end -- cgit