summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@rimspace.net>2011-08-12 06:21:35 -0700
committerDaniel Pittman <daniel@rimspace.net>2011-08-12 06:21:35 -0700
commiteee90dd5036c0627ab83c7a39c53d4ca3f0affc3 (patch)
treeca0218385aa113284eff6a76eaa95d0c543b900e /spec/unit
parent44719fcf9f9053a7be1bea59d516f24d2234ede4 (diff)
parent000b8fef6a33e5c9f56c0801523de15a0e5bc30b (diff)
downloadpuppet-eee90dd5036c0627ab83c7a39c53d4ca3f0affc3.tar.gz
puppet-eee90dd5036c0627ab83c7a39c53d4ca3f0affc3.tar.xz
puppet-eee90dd5036c0627ab83c7a39c53d4ca3f0affc3.zip
Merge pull request #23 from domcleal/tickets/master/5606
(#5606) Print Augeas' /augeas//error info to debug on save failure
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/provider/augeas/augeas_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb
index 434a99d70..f8c4aa151 100755
--- a/spec/unit/provider/augeas/augeas_spec.rb
+++ b/spec/unit/provider/augeas/augeas_spec.rb
@@ -442,6 +442,20 @@ describe provider_class do
@provider.expects(:diff).with("#{file}", "#{file}.augnew").returns("")
@provider.should be_need_to_run
end
+
+ it "should fail with an error if saving fails" do
+ file = "/etc/hosts"
+
+ @resource[:context] = "/files"
+ @resource[:changes] = ["set #{file}/foo bar"]
+
+ @augeas_stub.stubs(:save).returns(false)
+ @augeas_stub.stubs(:match).with("/augeas/events/saved").returns([])
+ @augeas_stub.expects(:close)
+
+ @provider.expects(:diff).never()
+ lambda { @provider.need_to_run? }.should raise_error
+ end
end
end
@@ -592,4 +606,22 @@ describe provider_class do
@provider.execute_changes.should == :executed
end
end
+
+ describe "save failure reporting" do
+ before do
+ @resource = stub("resource")
+ @augeas = stub("augeas")
+ @provider = provider_class.new(@resource)
+ @provider.aug = @augeas
+ end
+
+ it "should find errors and output to debug" do
+ @augeas.expects(:match).with("/augeas//error[. = 'put_failed']").returns(["/augeas/files/foo/error"])
+ @augeas.expects(:match).with("/augeas/files/foo/error/*").returns(["/augeas/files/foo/error/path", "/augeas/files/foo/error/message"])
+ @augeas.expects(:get).with("/augeas/files/foo/error/path").returns("/foo")
+ @augeas.expects(:get).with("/augeas/files/foo/error/message").returns("Failed to...")
+ @provider.expects(:debug).times(3)
+ @provider.print_put_errors
+ end
+ end
end