[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, upstream, updated. 3a39dd8353b6308cf49522990104cc63e55d7cda

James Turnbull james at lovedthanlost.net
Fri Jan 29 17:22:24 UTC 2010


The following commit has been merged in the upstream branch:
commit a6adf59ec4683af8dea9af1f8a457cb5a1ae178b
Author: Paul Nasrat <pnasrat at googlemail.com>
Date:   Wed May 6 08:14:37 2009 +0100

    Facter ticket  2214 - Fix facts for OVS
    
    Added tests for operatingsystem fact covering the two simple cases and a test
    for this specific interaction of release files
    
    We should take some time to add tests when we're adding or changing new
    operatingsystem facts

diff --git a/lib/facter/operatingsystem.rb b/lib/facter/operatingsystem.rb
index 704b48f..335003a 100644
--- a/lib/facter/operatingsystem.rb
+++ b/lib/facter/operatingsystem.rb
@@ -23,9 +23,11 @@ Facter.add(:operatingsystem) do
         elsif FileTest.exists?("/etc/arch-release")
             "Archlinux"
         elsif FileTest.exists?("/etc/enterprise-release")
-            "OEL"
-        elsif FileTest.exists?("/etc/ovs-release")
-            "OVS"
+            if FileTest.exists?("/etc/ovs-release")
+                "OVS"
+            else
+                "OEL"
+            end
         elsif FileTest.exists?("/etc/arch-release")
             "Arch"
         elsif FileTest.exists?("/etc/redhat-release")
diff --git a/spec/unit/operatingsystem.rb b/spec/unit/operatingsystem.rb
new file mode 100644
index 0000000..4c3fb3b
--- /dev/null
+++ b/spec/unit/operatingsystem.rb
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../spec_helper'
+
+require 'facter'
+
+describe "Operating System fact" do
+    
+    
+    after do
+        Facter.clear
+    end
+    
+    it "should default to the kernel name" do
+        Facter.fact(:kernel).stubs(:value).returns("Nutmeg")
+
+        Facter.fact(:operatingsystem).value.should == "Nutmeg"
+    end
+    
+    it "should be Solaris for SunOS" do
+         Facter.fact(:kernel).stubs(:value).returns("SunOS")
+         
+         Facter.fact(:operatingsystem).value.should == "Solaris"
+    end
+    
+    it "should identify Oracle VM as OVS" do
+
+        Facter.fact(:kernel).stubs(:value).returns("Linux")
+        FileTest.stubs(:exists?).returns false
+
+        FileTest.expects(:exists?).with("/etc/ovs-release").returns true
+        FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
+        
+        Facter.fact(:operatingsystem).value.should == "OVS"
+    end
+end

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list