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

Paul Nasrat pnasrat at googlemail.com
Fri Jan 23 14:21:25 UTC 2009


The following commit has been merged in the master branch:
commit 157c0ddff032bb78838a1448eb1ff989bf1da705
Author: Paul Nasrat <pnasrat at googlemail.com>
Date:   Sat Oct 11 08:12:22 2008 +0100

    Fix 1642 (always warning) and improve unit tests to cover when to warn and not

diff --git a/lib/puppet/type/file/checksum.rb b/lib/puppet/type/file/checksum.rb
index 27edee1..785ed0f 100755
--- a/lib/puppet/type/file/checksum.rb
+++ b/lib/puppet/type/file/checksum.rb
@@ -53,7 +53,7 @@ Puppet::Type.type(:file).newproperty(:checksum) do
         else
             if FileTest.directory?(@resource[:path])
                 return :time
-            elsif @resource[:source]
+            elsif @resource[:source] and value.to_s != "md5"
                  self.warning("Files with source set must use md5 as checksum. Forcing to md5 from %s for %s" % [ value, @resource[:path] ])
                 return :md5
             else
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 552d284..0b7bfa8 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -41,14 +41,38 @@ describe Puppet::Type.type(:file) do
             lambda { @file.retrieve }.should raise_error(Puppet::Error)
         end
 
-        it "should always have a checksum type of md5" do
+        it "should have a checksum type of md5 and warn if retrieving with mtime" do
             File.open(@path, "w") do |f| f.puts "foo" end
+            @file.property(:checksum).expects(:warning).with("Files with source set must use md5 as checksum. Forcing to md5 from %s for %s" % [:mtime, @path]) 
             @file[:checksum] = :mtime
             @file.property(:checksum).checktype.should == :md5
             @file.property(:checksum).retrieve.should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
+        end
+
+        it "should have a checksum type of md5 and warn if retrieving with md5lite" do
+            File.open(@path, "w") do |f| f.puts "foo" end
+            @file.property(:checksum).expects(:warning).with("Files with source set must use md5 as checksum. Forcing to md5 from %s for %s" % [:md5lite, @path]) 
+            @file[:checksum] = :md5lite
+            @file.property(:checksum).checktype.should == :md5
+            @file.property(:checksum).retrieve.should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
+        end
+
+
+        it "should have a checksum type of md5 if getsum called with mtime" do
+            File.open(@path, "w") do |f| f.puts "foo" end
+            @file[:checksum] = :md5
+            @file.property(:checksum).checktype.should == :md5
             @file.property(:checksum).getsum(:mtime).should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
         end
 
+        it "should not warn if sumtype set to md5" do
+            File.open(@path, "w") do |f| f.puts "foo" end
+            @file.property(:checksum).expects(:warning).never
+            @file[:checksum] = :md5
+            @file.property(:checksum).checktype.should == :md5
+            @file.property(:checksum).retrieve.should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
+        end
+
     end
 
     describe "when retrieving remote files" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list