diff options
| author | Paul Berry <paul@puppetlabs.com> | 2011-01-11 11:45:58 -0800 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2011-01-11 11:45:58 -0800 |
| commit | bf2b07158f5e4e16e7a1a52e84257ae5d84d9e1c (patch) | |
| tree | cf51e75f954847fda264b561a7a3acdfa5869dda /spec/unit | |
| parent | e6e88e7df7fa1cbec1400d73cb7ba9428c420be0 (diff) | |
| parent | a002231f45339da9b152162c2f48126d95e2e246 (diff) | |
| download | puppet-bf2b07158f5e4e16e7a1a52e84257ae5d84d9e1c.tar.gz puppet-bf2b07158f5e4e16e7a1a52e84257ae5d84d9e1c.tar.xz puppet-bf2b07158f5e4e16e7a1a52e84257ae5d84d9e1c.zip | |
Merge branch 'ticket/2.6.next/5171-filebucket-diff' into 2.6.next
* ticket/2.6.next/5171-filebucket-diff:
(#5171) Made filebucket able to perform diffs
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/indirector/file_bucket_file/file_spec.rb | 45 | ||||
| -rwxr-xr-x | spec/unit/network/http/handler_spec.rb | 6 |
2 files changed, 51 insertions, 0 deletions
diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb index aa3ade6b6..7bf02b5b3 100755 --- a/spec/unit/indirector/file_bucket_file/file_spec.rb +++ b/spec/unit/indirector/file_bucket_file/file_spec.rb @@ -13,6 +13,51 @@ describe Puppet::FileBucketFile::File do Puppet::FileBucketFile::File.doc.should be_instance_of(String) end + describe "non-stubbing tests" do + include PuppetSpec::Files + + before do + Puppet[:bucketdir] = tmpdir('bucketdir') + end + + describe "when diffing files" do + def save_bucket_file(contents) + bucket_file = Puppet::FileBucket::File.new(contents) + bucket_file.save + bucket_file.checksum_data + end + + it "should generate an empty string if there is no diff" do + checksum = save_bucket_file("I'm the contents of a file") + Puppet::FileBucket::File.find("md5/#{checksum}", :diff_with => checksum).should == '' + end + + it "should generate a proper diff if there is a diff" do + checksum1 = save_bucket_file("foo\nbar\nbaz") + checksum2 = save_bucket_file("foo\nbiz\nbaz") + diff = Puppet::FileBucket::File.find("md5/#{checksum1}", :diff_with => checksum2) + diff.should == <<HERE +2c2 +< bar +--- +> biz +HERE + end + + it "should raise an exception if the hash to diff against isn't found" do + checksum = save_bucket_file("whatever") + bogus_checksum = "d1bf072d0e2c6e20e3fbd23f022089a1" + lambda { Puppet::FileBucket::File.find("md5/#{checksum}", :diff_with => bogus_checksum) }.should raise_error "could not find diff_with #{bogus_checksum}" + end + + it "should return nil if the hash to diff from isn't found" do + checksum = save_bucket_file("whatever") + bogus_checksum = "d1bf072d0e2c6e20e3fbd23f022089a1" + Puppet::FileBucket::File.find("md5/#{bogus_checksum}", :diff_with => checksum).should == nil + end + end + end + describe "when initializing" do it "should use the filebucket settings section" do Puppet.settings.expects(:use).with(:filebucket) diff --git a/spec/unit/network/http/handler_spec.rb b/spec/unit/network/http/handler_spec.rb index 76a9c5530..cdbce41f7 100755 --- a/spec/unit/network/http/handler_spec.rb +++ b/spec/unit/network/http/handler_spec.rb @@ -209,6 +209,12 @@ describe Puppet::Network::HTTP::Handler do @handler.do_find(@irequest, @request, @response) end + it "should pass the result through without rendering it if the result is a string" do + @model_class.stubs(:find).returns "foo" + @handler.expects(:set_response).with(@response, "foo") + @handler.do_find(@irequest, @request, @response) + end + it "should use the default status when a model find call succeeds" do @handler.expects(:set_response).with { |response, body, status| status.nil? } @handler.do_find(@irequest, @request, @response) |
