[Pkg-puppet-devel] [facter] 136/180: (maint) Fix regression in openbsd manufacturer facts

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 3128a4d676ef5cf7a7c243648042372c81d94f0b
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Mon Jun 16 18:00:59 2014 -0700

    (maint) Fix regression in openbsd manufacturer facts
---
 lib/facter/util/manufacturer.rb     |  2 +-
 spec/unit/util/manufacturer_spec.rb | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb
index d769036..ccd2d14 100644
--- a/lib/facter/util/manufacturer.rb
+++ b/lib/facter/util/manufacturer.rb
@@ -53,7 +53,7 @@ module Facter::Manufacturer
     name.each do |sysctlkey,facterkey|
       Facter.add(facterkey) do
         confine :kernel => [:openbsd, :darwin]
-        setcode Facter::Util::POSIX.sysctl(sysctlkey)
+        setcode { Facter::Util::POSIX.sysctl(sysctlkey) }
       end
     end
   end
diff --git a/spec/unit/util/manufacturer_spec.rb b/spec/unit/util/manufacturer_spec.rb
index 24aa91d..b2265d5 100755
--- a/spec/unit/util/manufacturer_spec.rb
+++ b/spec/unit/util/manufacturer_spec.rb
@@ -187,4 +187,37 @@ Handle 0x001F
     Facter.value(:serialnumber).should == "56 4d 40 2b 4d 81 94 d6-e6 c5 56 a4 56 0c 9e 9f"
     Facter.value(:productname).should == "VMware Virtual Platform"
   end
+
+  describe "using sysctl to look up manufacturer information" do
+    before do
+      Facter.fact(:kernel).stubs(:value).returns 'OpenBSD'
+    end
+
+    let(:mfg_keys) do
+      {
+        'hw.vendor'   => 'manufacturer',
+        'hw.product'  => 'productname',
+        'hw.serialno' => 'serialnumber'
+      }
+    end
+
+    it "creates a new fact for the each hash key" do
+      mfg_keys.values.each do |value|
+        Facter.expects(:add).with(value)
+      end
+      described_class.sysctl_find_system_info(mfg_keys)
+    end
+
+    it "uses sysctl to determine the value for that fact" do
+      mfg_keys.keys.each do |sysctl|
+        Facter::Util::POSIX.expects(:sysctl).with(sysctl).returns "sysctl #{sysctl}"
+      end
+
+      described_class.sysctl_find_system_info(mfg_keys)
+
+      mfg_keys.invert.each_pair do |factname, value|
+        expect(Facter.value(factname)).to eq "sysctl #{value}"
+      end
+    end
+  end
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list