diff options
author | Markus Roberts <Markus@reality.com> | 2009-10-31 12:13:55 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-11-05 18:56:55 +1100 |
commit | b8470b8064503baea21d43d5c1dcf349bc4daf59 (patch) | |
tree | efea7a9ac5bd5d16665d1c8ac1b4b568dd95799a /spec | |
parent | 5b750c225ff0c646341282aa867d92dbe15509cd (diff) | |
download | puppet-b8470b8064503baea21d43d5c1dcf349bc4daf59.tar.gz puppet-b8470b8064503baea21d43d5c1dcf349bc4daf59.tar.xz puppet-b8470b8064503baea21d43d5c1dcf349bc4daf59.zip |
Fix #2757 & CSR 92 (symlinks in recursively managed dirs)
The fundemental problem was that, despite what the comment said,
the early bailout for file content management only applied to
directories, not to links. Making links bail out at as well fixed
the problem for most users.
However, it would still occur for users with mixed ruby version
system since there were no to_/from_pson methods for file metadata.
So the second (and far larger) part of this patch adds metadata
pson support.
The testing is unit level only, as there's no pratical way to do
the cross-ruby-version acceptance testing and no benifit to doing
"integration" testing short of that.
Signed-off-by: Markus Roberts <Markus@reductivelabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/file_serving/metadata.rb | 78 | ||||
-rwxr-xr-x | spec/unit/network/rights.rb | 2 | ||||
-rwxr-xr-x | spec/unit/type/file/content.rb | 9 |
3 files changed, 88 insertions, 1 deletions
diff --git a/spec/unit/file_serving/metadata.rb b/spec/unit/file_serving/metadata.rb index de0c4570c..c27efd6bb 100755 --- a/spec/unit/file_serving/metadata.rb +++ b/spec/unit/file_serving/metadata.rb @@ -20,6 +20,84 @@ describe Puppet::FileServing::Metadata do it "should have a method that triggers attribute collection" do Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:collect) end + + it "should support pson serialization" do + Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson) + end + + it "should support to_pson_data_hash" do + Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson_data_hash) + end + + it "should support pson deserialization" do + Puppet::FileServing::Metadata.should respond_to(:from_pson) + end + + describe "when serializing" do + before do + @metadata = Puppet::FileServing::Metadata.new("/foo/bar") + end + it "should perform pson serialization by calling to_pson on it's pson_data_hash" do + pdh = mock "data hash" + pdh_as_pson = mock "data as pson" + @metadata.expects(:to_pson_data_hash).returns pdh + pdh.expects(:to_pson).returns pdh_as_pson + @metadata.to_pson.should == pdh_as_pson + end + + it "should serialize as FileMetadata" do + @metadata.to_pson_data_hash['document_type'].should == "FileMetadata" + end + + it "the data should include the path, relative_path, links, owner, group, mode, checksum, type, and destination" do + @metadata.to_pson_data_hash['data'].keys.sort.should == %w{ path relative_path links owner group mode checksum type destination }.sort + end + + it "should pass the path in the hash verbatum" do + @metadata.to_pson_data_hash['data']['path'] == @metadata.path + end + + it "should pass the relative_path in the hash verbatum" do + @metadata.to_pson_data_hash['data']['relative_path'] == @metadata.relative_path + end + + it "should pass the links in the hash verbatum" do + @metadata.to_pson_data_hash['data']['links'] == @metadata.links + end + + it "should pass the path owner in the hash verbatum" do + @metadata.to_pson_data_hash['data']['owner'] == @metadata.owner + end + + it "should pass the group in the hash verbatum" do + @metadata.to_pson_data_hash['data']['group'] == @metadata.group + end + + it "should pass the mode in the hash verbatum" do + @metadata.to_pson_data_hash['data']['mode'] == @metadata.mode + end + + it "should pass the ftype in the hash verbatum as the 'type'" do + @metadata.to_pson_data_hash['data']['type'] == @metadata.ftype + end + + it "should pass the destination verbatum" do + @metadata.to_pson_data_hash['data']['destination'] == @metadata.destination + end + + it "should pass the checksum in the hash as a nested hash" do + @metadata.to_pson_data_hash['data']['checksum'].should be_is_a Hash + end + + it "should pass the checksum_type in the hash verbatum as the checksum's type" do + @metadata.to_pson_data_hash['data']['checksum']['type'] == @metadata.checksum_type + end + + it "should pass the checksum in the hash verbatum as the checksum's value" do + @metadata.to_pson_data_hash['data']['checksum']['value'] == @metadata.checksum + end + + end end describe Puppet::FileServing::Metadata, " when finding the file to use for setting attributes" do diff --git a/spec/unit/network/rights.rb b/spec/unit/network/rights.rb index 244fa18c8..7f00891ac 100755 --- a/spec/unit/network/rights.rb +++ b/spec/unit/network/rights.rb @@ -391,7 +391,7 @@ describe Puppet::Network::Rights do end it "should match as a regex" do - @acl.match?("this shoud work.rb").should_not be_nil + @acl.match?("this should work.rb").should_not be_nil end it "should return nil if no match" do diff --git a/spec/unit/type/file/content.rb b/spec/unit/type/file/content.rb index 8bdb1f226..901d52d74 100755 --- a/spec/unit/type/file/content.rb +++ b/spec/unit/type/file/content.rb @@ -119,6 +119,15 @@ describe content do @content.retrieve.should be_nil end + it "should not manage content on links" do + @content = content.new(:resource => @resource) + + stat = mock 'stat', :ftype => "link" + @resource.expects(:stat).returns stat + + @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" |