+1 Works for me

On Oct 11, 2008, at 2:14 AM, Paul Nasrat wrote:

>
>
> Signed-off-by: Paul Nasrat <[EMAIL PROTECTED]>
> ---
> lib/puppet/type/file/checksum.rb |    2 +-
> spec/unit/type/file.rb           |   26 +++++++++++++++++++++++++-
> 2 files changed, 26 insertions(+), 2 deletions(-)
>
> 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
> -- 
> 1.5.3.4
>
>
> >


-- 
A gentleman is a man who can play the accordion but doesn't. --Unknown
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
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