summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-12-31 01:04:06 -0800
committerJames Turnbull <james@lovedthanlost.net>2010-01-01 11:24:21 +1100
commit7e64393dd10023d528d2fc21383ead30c9ee94dd (patch)
treebc2fa8b52be1a866df4d3ec0710e5bb7a04d916d /spec
parent7e2e12be7827c2adb64a192b5b7176c7c541af44 (diff)
Additional fix for #2994 (followed symlinks do not have checksums)
The first patch for #2994, to which this is an extension, exposed the fact that checksums were not being included in the metadata for followed links; checksums are needed for managing the contents of files that are represented on the server as links (links => follow). This patch adds checksums for followed links and tests to confirm that it works as expected.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/file_serving/metadata.rb46
1 files changed, 30 insertions, 16 deletions
diff --git a/spec/unit/file_serving/metadata.rb b/spec/unit/file_serving/metadata.rb
index 38240f7e4..a3078faf7 100755
--- a/spec/unit/file_serving/metadata.rb
+++ b/spec/unit/file_serving/metadata.rb
@@ -230,23 +230,37 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
end
describe Puppet::FileServing::Metadata, " when pointing to a link" do
- it "should store the destination of the link in :destination if links are :manage" do
- file = Puppet::FileServing::Metadata.new("/base/path/my/file", :links => :manage)
-
- File.expects(:lstat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "link", :mode => 0755)
- File.expects(:readlink).with("/base/path/my/file").returns "/some/other/path"
-
- file.collect
- file.destination.should == "/some/other/path"
+ describe "when links are managed" do
+ before do
+ @file = Puppet::FileServing::Metadata.new("/base/path/my/file", :links => :manage)
+ File.expects(:lstat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "link", :mode => 0755)
+ File.expects(:readlink).with("/base/path/my/file").returns "/some/other/path"
+ end
+ it "should store the destination of the link in :destination if links are :manage" do
+ @file.collect
+ @file.destination.should == "/some/other/path"
+ end
+ it "should not collect the checksum if links are :manage" do
+ @file.collect
+ @file.checksum.should be_nil
+ end
end
- it "should not collect the checksum" do
- file = Puppet::FileServing::Metadata.new("/base/path/my/file", :links => :manage)
-
- File.expects(:lstat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "link", :mode => 0755)
- File.expects(:readlink).with("/base/path/my/file").returns "/some/other/path"
-
- file.collect
- file.checksum.should be_nil
+ describe "when links are followed" do
+ before do
+ @file = Puppet::FileServing::Metadata.new("/base/path/my/file", :links => :follow)
+ File.expects(:stat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "file", :mode => 0755)
+ File.expects(:readlink).with("/base/path/my/file").never
+ @checksum = Digest::MD5.hexdigest("some content\n")
+ @file.stubs(:md5_file).returns(@checksum)
+ end
+ it "should not store the destination of the link in :destination if links are :follow" do
+ @file.collect
+ @file.destination.should be_nil
+ end
+ it "should collect the checksum if links are :follow" do
+ @file.collect
+ @file.checksum.should == "{md5}#{@checksum}"
+ end
end
end