[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Jesse Wolfe jes5199 at gmail.com
Thu Mar 17 10:49:46 UTC 2011


The following commit has been merged in the upstream branch:
commit 4f34dbf206e591614c2fc06ce9bed1628ee85715
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Tue Mar 15 15:29:01 2011 -0700

    Fix #5610: Prevent unnecessary RAL lookups
    
    Reviewed-By: Paul Berry <paul at puppetlabs.com>

diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 205d809..d24cc85 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -200,7 +200,7 @@ class Type
   end
 
   def uniqueness_key
-    to_resource.uniqueness_key
+    self.class.key_attributes.sort_by { |attribute_name| attribute_name.to_s }.map{ |attribute_name| self[attribute_name] }
   end
 
   # Create a new parameter.  Requires a block and a name, stores it in the
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index b7a0897..6d9d0b2 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -434,7 +434,7 @@ describe Puppet::Type do
         patterns.length.should == 1
         patterns[0].length.should == 2
       end
-      
+
       it "should have a regexp that captures the entire string" do
         patterns = @type_class.title_patterns
         string = "abc\n\tdef"
@@ -570,4 +570,15 @@ describe Puppet::Type.metaparamclass(:audit) do
     @resource[:audit] = :noop
     @resource.parameter(:noop).should be_nil
   end
+
+  describe "when generating the uniqueness key" do
+    it "should include all of the key_attributes in alphabetical order by attribute name" do
+      Puppet::Type.type(:file).stubs(:key_attributes).returns [:path, :mode, :owner]
+      Puppet::Type.type(:file).stubs(:title_patterns).returns(
+        [ [ /(.*)/, [ [:path, lambda{|x| x} ] ] ] ]
+      )
+      res = Puppet::Type.type(:file).new( :title => '/my/file', :path => '/my/file', :owner => 'root', :content => 'hello' )
+      res.uniqueness_key.should == [ nil, 'root', '/my/file']
+    end
+  end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list