[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:21:26 UTC 2009


The following commit has been merged in the master branch:
commit a74ec60d33dee1c592ec858faeccc23d7a7b79f3
Author: Luke Kanies <luke at madstop.com>
Date:   Thu Oct 16 16:17:30 2008 -0500

    Fixing tests I broke when trying to fix the Providers reference.
    
    Signed-off-by: Luke Kanies <luke at madstop.com>

diff --git a/CHANGELOG b/CHANGELOG
index b470476..abd1856 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
 0.24.6
+    Fixed #1655 - Provider::Confine::Variable tests are broken
+
     Fixed #1646 - service puppet status does not work as non-root 
     on redhat system
 
diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb
index 3333563..0ef90d6 100644
--- a/lib/puppet/provider/confine/variable.rb
+++ b/lib/puppet/provider/confine/variable.rb
@@ -1,11 +1,19 @@
 require 'puppet/provider/confine'
 
+# Require a specific value for a variable, either a Puppet setting
+# or a Facter value.  This class is a bit weird because the name
+# is set explicitly by the ConfineCollection class -- from this class,
+# it's not obvious how the name would ever get set.
 class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
+    # Provide a hash summary of failing confines -- the key of the hash
+    # is the name of the confine, and the value is the missing yet required values.
+    # Only returns failed values, not all required values.
     def self.summarize(confines)
         result = Hash.new { |hash, key| hash[key] = [] }
-        confines.inject(result) { |total, confine| total[confine.class.name] += confine.values unless confine.valid?; total }
+        confines.inject(result) { |total, confine| total[confine.name] += confine.values unless confine.valid?; total }
     end
 
+    # This is set by ConfineCollection.
     attr_accessor :name
 
     # Retrieve the value from facter
@@ -20,6 +28,7 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
         "facter value '%s' for '%s' not in required list '%s'" % [value, self.name, values.join(",")]
     end
 
+    # Compare the passed-in value to the retrieved value.
     def pass?(value)
         test_value.downcase.to_s == value.to_s.downcase
     end
diff --git a/spec/unit/provider/confine/variable.rb b/spec/unit/provider/confine/variable.rb
index 093301b..38b3dad 100755
--- a/spec/unit/provider/confine/variable.rb
+++ b/spec/unit/provider/confine/variable.rb
@@ -85,16 +85,26 @@ describe Puppet::Provider::Confine::Variable do
 
     describe "when summarizing multiple instances" do
         it "should return a hash of failing variables and their values" do
-            c1 = stub '1', :valid? => false, :values => %w{one}, :fact => "uno"
-            c2 = stub '2', :valid? => true,  :values => %w{two}, :fact => "dos"
-            c3 = stub '3', :valid? => false, :values => %w{three}, :fact => "tres"
+            c1 = Puppet::Provider::Confine::Variable.new("one")
+            c1.name = "uno"
+            c1.expects(:valid?).returns false
+            c2 = Puppet::Provider::Confine::Variable.new("two")
+            c2.name = "dos"
+            c2.expects(:valid?).returns true
+            c3 = Puppet::Provider::Confine::Variable.new("three")
+            c3.name = "tres"
+            c3.expects(:valid?).returns false
 
             Puppet::Provider::Confine::Variable.summarize([c1, c2, c3]).should == {"uno" => %w{one}, "tres" => %w{three}}
         end
 
         it "should combine the values of multiple confines with the same fact" do
-            c1 = stub '1', :valid? => false, :values => %w{one}, :fact => "uno"
-            c2 = stub '2', :valid? => false,  :values => %w{two}, :fact => "uno"
+            c1 = Puppet::Provider::Confine::Variable.new("one")
+            c1.name = "uno"
+            c1.expects(:valid?).returns false
+            c2 = Puppet::Provider::Confine::Variable.new("two")
+            c2.name = "uno"
+            c2.expects(:valid?).returns false
 
             Puppet::Provider::Confine::Variable.summarize([c1, c2]).should == {"uno" => %w{one two}}
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list