diff options
| author | Daniel Pittman <daniel@rimspace.net> | 2011-08-12 06:21:35 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@rimspace.net> | 2011-08-12 06:21:35 -0700 |
| commit | eee90dd5036c0627ab83c7a39c53d4ca3f0affc3 (patch) | |
| tree | ca0218385aa113284eff6a76eaa95d0c543b900e /spec/unit | |
| parent | 44719fcf9f9053a7be1bea59d516f24d2234ede4 (diff) | |
| parent | 000b8fef6a33e5c9f56c0801523de15a0e5bc30b (diff) | |
| download | puppet-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-x | spec/unit/provider/augeas/augeas_spec.rb | 32 |
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 |
