summaryrefslogtreecommitdiffstats
path: root/spec/unit/file_bucket
diff options
context:
space:
mode:
authorPaul Berry <paul@puppetlabs.com>2011-02-21 12:50:53 -0800
committerPaul Berry <paul@puppetlabs.com>2011-02-21 13:53:02 -0800
commitdcce45cfcbf77d576237ae8ff0ffa6ef98dcb722 (patch)
treebbb656f24a5e4c01eaaee0688b43299053426f8c /spec/unit/file_bucket
parentbca53bd4dcaf39a09f91c32ff56ef3b0a60dc85c (diff)
downloadpuppet-dcce45cfcbf77d576237ae8ff0ffa6ef98dcb722.tar.gz
puppet-dcce45cfcbf77d576237ae8ff0ffa6ef98dcb722.tar.xz
puppet-dcce45cfcbf77d576237ae8ff0ffa6ef98dcb722.zip
(#6353) Restore the ability to store paths in the filebucket
Commit 2274d5104f6e413a2b8899a3c3111a17bbb2f4d7 optimized network usage for the case where a file is already in the filebucket. However, it took away the ability to store paths. This change restores the ability to store paths while maintaining optimal network usage for the case where the file is already in the filebucket with the given path. This is expected to be the most common case. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
Diffstat (limited to 'spec/unit/file_bucket')
-rwxr-xr-xspec/unit/file_bucket/dipper_spec.rb2
-rw-r--r--spec/unit/file_bucket/file_spec.rb35
2 files changed, 1 insertions, 36 deletions
diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb
index db40c6296..c40d79589 100755
--- a/spec/unit/file_bucket/dipper_spec.rb
+++ b/spec/unit/file_bucket/dipper_spec.rb
@@ -92,7 +92,7 @@ describe Puppet::FileBucket::Dipper do
[request1, request2].each do |r|
r.server.should == 'puppetmaster'
r.port.should == 31337
- r.key.should == "md5/#{checksum}"
+ r.key.should == "md5/#{checksum}#{real_path}"
end
end
diff --git a/spec/unit/file_bucket/file_spec.rb b/spec/unit/file_bucket/file_spec.rb
index 82063c2e3..f80b16238 100644
--- a/spec/unit/file_bucket/file_spec.rb
+++ b/spec/unit/file_bucket/file_spec.rb
@@ -64,30 +64,6 @@ describe Puppet::FileBucket::File do
end
end
- describe "when saving files" do
- it "should save the contents to the calculated path" do
- ::File.stubs(:directory?).with(@dir).returns(true)
- ::File.expects(:exist?).with("#{@dir}/contents").returns false
-
- mockfile = mock "file"
- mockfile.expects(:print).with(@contents)
- ::File.expects(:open).with("#{@dir}/contents", ::File::WRONLY|::File::CREAT, 0440).yields(mockfile)
-
- Puppet::FileBucket::File.new(@contents).save
- end
-
- it "should make any directories necessary for storage" do
- FileUtils.expects(:mkdir_p).with do |arg|
- ::File.umask == 0007 and arg == @dir
- end
- ::File.expects(:directory?).with(@dir).returns(false)
- ::File.expects(:open).with("#{@dir}/contents", ::File::WRONLY|::File::CREAT, 0440)
- ::File.expects(:exist?).with("#{@dir}/contents").returns false
-
- Puppet::FileBucket::File.new(@contents).save
- end
- end
-
it "should return a url-ish name" do
Puppet::FileBucket::File.new(@contents).name.should == "md5/4a8ec4fa5f01b4ab1a0ab8cbccb709f0"
end
@@ -105,17 +81,6 @@ describe Puppet::FileBucket::File do
Puppet::FileBucket::File.from_pson({"contents"=>"file contents"}).contents.should == "file contents"
end
- it "should save a file" do
- ::File.expects(:exist?).with("#{@dir}/contents").returns false
- ::File.expects(:directory?).with(@dir).returns false
- ::FileUtils.expects(:mkdir_p).with(@dir)
- ::File.expects(:open).with("#{@dir}/contents", ::File::WRONLY|::File::CREAT, 0440)
-
- bucketfile = Puppet::FileBucket::File.new(@contents)
- bucketfile.save
-
- end
-
def make_bucketed_file
FileUtils.mkdir_p(@dir)
File.open("#{@dir}/contents", 'w') { |f| f.write @contents }