diff options
-rw-r--r-- | lib/puppet/network/client/dipper.rb | 7 | ||||
-rwxr-xr-x | spec/unit/network/client/dipper.rb | 16 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/puppet/network/client/dipper.rb b/lib/puppet/network/client/dipper.rb index 8616d4f73..0e2dc1425 100644 --- a/lib/puppet/network/client/dipper.rb +++ b/lib/puppet/network/client/dipper.rb @@ -25,7 +25,12 @@ class Puppet::Network::Client::Dipper < Puppet::Network::Client unless local? contents = Base64.encode64(contents) end - return @driver.addfile(contents,file) + begin + return @driver.addfile(contents,file) + rescue => detail + puts detail.backtrace if Puppet[:trace] + raise Puppet::Error, "Could not back up %s: %s" % [file, detail] + end end # Retrieve a file by sum. diff --git a/spec/unit/network/client/dipper.rb b/spec/unit/network/client/dipper.rb new file mode 100755 index 000000000..d1631fbb5 --- /dev/null +++ b/spec/unit/network/client/dipper.rb @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +describe Puppet::Network::Client.dipper do + it "should fail in an informative way when there are failures backing up to the server" do + FileTest.stubs(:exists?).returns true + File.stubs(:read).returns "content" + + @dipper = Puppet::Network::Client::Dipper.new(:Path => "/my/bucket") + + @dipper.driver.expects(:addfile).raises ArgumentError + + lambda { @dipper.backup("/my/file") }.should raise_error(Puppet::Error) + end +end |