Greetings!

Please review the pull request #61: (#9517) Fix physicalprocessorcount on windows opened by (haus)

Some more information about the pull request:

  • Opened: Wed Sep 21 17:49:05 UTC 2011
  • Based on: puppetlabs:1.6rc (ef0a9aa3e36b3714439e9e0c23828313075ba411)
  • Requested merge: haus:ticket/1.6rc/9517 (3117e82a87f93f7bd2ae41c6dfcf65d58ce17f4f)

Description:

A broken test led to a broken fact. The WMI.execquery was incorrectly stubbed
to return an array when the actual WMI.execquery does not return an array. This
means that length, which works on arrays, does not work with WMI.execquery.
This fixes both the fact and the test. The test is unfortunately lifted to a
higher level, but it has the benefit of being correct.

Thanks to Eric Stonfer for the fact fix.

Signed-off-by: Matthaus Litteken [email protected]

Thanks!
The Pull Request Bot

Diff follows:

diff --git a/lib/facter/physicalprocessorcount.rb b/lib/facter/physicalprocessorcount.rb
index 13e380f..082deac 100644
--- a/lib/facter/physicalprocessorcount.rb
+++ b/lib/facter/physicalprocessorcount.rb
@@ -59,6 +59,6 @@ Facter.add('physicalprocessorcount') do
   confine :kernel => :windows
   setcode do
     require 'facter/util/wmi'
-    Facter::Util::WMI.execquery("select Name from Win32_Processor").length
+    Facter::Util::WMI.execquery("select Name from Win32_Processor").Count
   end
 end
diff --git a/spec/unit/physicalprocessorcount_spec.rb b/spec/unit/physicalprocessorcount_spec.rb
index 3cf1ae2..8d33cb5 100755
--- a/spec/unit/physicalprocessorcount_spec.rb
+++ b/spec/unit/physicalprocessorcount_spec.rb
@@ -42,7 +42,9 @@ describe "Physical processor count facts" do
         Facter.fact(:kernel).stubs(:value).returns("windows")
 
         require 'facter/util/wmi'
-        Facter::Util::WMI.stubs(:execquery).with("select Name from Win32_Processor").returns(Array.new(4))
+        ole = stub 'WIN32OLE'
+        Facter::Util::WMI.expects(:execquery).with("select Name from Win32_Processor").returns(ole)
+        ole.stubs(:Count).returns(4)
 
         Facter.fact(:physicalprocessorcount).value.should == 4
     end

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to