summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-03-10 00:27:46 -0500
committerLuke Kanies <luke@madstop.com>2009-03-10 00:27:46 -0500
commit858480b04d84e56aa483c80642dd0512af4fd025 (patch)
treee5376c7911bc94e538aabbc8e242b7879754d0d2 /spec/unit
parent27aa21012d249bd39070115e6f640c0196bbdd81 (diff)
downloadpuppet-858480b04d84e56aa483c80642dd0512af4fd025.tar.gz
puppet-858480b04d84e56aa483c80642dd0512af4fd025.tar.xz
puppet-858480b04d84e56aa483c80642dd0512af4fd025.zip
Correctly handling non-string checksums
Content is now returning the checksum rather than the actual content, and the method of creating the full checksum wasn't correctly handling timestamps, which aren't strings and can't be the right side of a String + call. I've opened #2064 as a better long-term fix. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/type/file/content.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/unit/type/file/content.rb b/spec/unit/type/file/content.rb
index fd225fa17..0529cd33f 100755
--- a/spec/unit/type/file/content.rb
+++ b/spec/unit/type/file/content.rb
@@ -119,6 +119,21 @@ describe content do
@content.retrieve.should be_nil
end
+ it "should always return the checksum as a string" do
+ @content = content.new(:resource => @resource)
+ @content.stubs(:checksum_type).returns "mtime"
+
+ stat = mock 'stat', :ftype => "file"
+ @resource.expects(:stat).returns stat
+
+ @resource.expects(:[]).with(:path).returns "/my/file"
+
+ time = Time.now
+ @content.expects(:mtime_file).with("/my/file").returns time
+
+ @content.retrieve.should == "{mtime}%s" % time
+ end
+
it "should return the checksum of the file if it exists and is a normal file" do
@content = content.new(:resource => @resource)
@content.stubs(:checksum_type).returns "md5"