diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-02 09:53:54 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-02 09:53:54 -0800 |
commit | bbe278f6ef9b945afe66ef8a4e71f46e83df9278 (patch) | |
tree | db305f3d7a288cb922b26370463ec13a86f988c6 | |
parent | 22ad70b28136a2f99362ec13af50f32c99756cac (diff) | |
download | chef-bbe278f6ef9b945afe66ef8a4e71f46e83df9278.tar.gz |
Update specs for yum package provider to use shell_out
-rw-r--r-- | lib/chef/provider/package/yum.rb | 3 | ||||
-rw-r--r-- | spec/unit/provider/package/yum_spec.rb | 28 |
2 files changed, 17 insertions, 14 deletions
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 4f90b5eb2e..22722f7f3c 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -1008,7 +1008,8 @@ class Chef end if status.exitstatus > 0 - status.error! + command_output = "STDOUT: #{status.stdout}\nSTDERR: #{status.stderr}" + raise Chef::Exceptions::Exec, "#{command} returned #{status.exitstatus}:\n#{command_output}" end end diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index aecbd1c34e..cd2b3decf4 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -696,9 +696,9 @@ describe Chef::Provider::Package::Yum do describe "when running yum" do it "should run yum once if it exits with a return code of 0" do - @status = double("Status", :exitstatus => 0) - allow(@provider).to receive(:output_of_command).and_return([@status, "", ""]) - expect(@provider).to receive(:output_of_command).once.with( + @status = double("Status", :exitstatus => 0, :stdout => "", :stderr => "") + allow(@provider).to receive(:shell_out).and_return(@status) + expect(@provider).to receive(:shell_out).once.with( "yum -d0 -e0 -y install emacs-1.0", {:timeout => Chef::Config[:yum_timeout]} ) @@ -706,9 +706,9 @@ describe Chef::Provider::Package::Yum do end it "should run yum once if it exits with a return code > 0 and no scriptlet failures" do - @status = double("Status", :exitstatus => 2) - allow(@provider).to receive(:output_of_command).and_return([@status, "failure failure", "problem problem"]) - expect(@provider).to receive(:output_of_command).once.with( + @status = double("Status", :exitstatus => 2, :stdout => "failure failure", :stderr => "problem problem") + allow(@provider).to receive(:shell_out).and_return(@status) + expect(@provider).to receive(:shell_out).once.with( "yum -d0 -e0 -y install emacs-1.0", {:timeout => Chef::Config[:yum_timeout]} ) @@ -716,9 +716,10 @@ describe Chef::Provider::Package::Yum do end it "should run yum once if it exits with a return code of 1 and %pre scriptlet failures" do - @status = double("Status", :exitstatus => 1) - allow(@provider).to receive(:output_of_command).and_return([@status, "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""]) - expect(@provider).to receive(:output_of_command).once.with( + @status = double("Status", :exitstatus => 1, :stdout => "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", + :stderr => "") + allow(@provider).to receive(:shell_out).and_return(@status) + expect(@provider).to receive(:shell_out).once.with( "yum -d0 -e0 -y install emacs-1.0", {:timeout => Chef::Config[:yum_timeout]} ) @@ -727,9 +728,10 @@ describe Chef::Provider::Package::Yum do end it "should run yum twice if it exits with a return code of 1 and %post scriptlet failures" do - @status = double("Status", :exitstatus => 1) - allow(@provider).to receive(:output_of_command).and_return([@status, "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""]) - expect(@provider).to receive(:output_of_command).twice.with( + @status = double("Status", :exitstatus => 1, :stdout => "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", + :stderr => "") + allow(@provider).to receive(:shell_out).and_return(@status) + expect(@provider).to receive(:shell_out).twice.with( "yum -d0 -e0 -y install emacs-1.0", {:timeout => Chef::Config[:yum_timeout]} ) @@ -2061,4 +2063,4 @@ describe "Chef::Provider::Package::Yum - Multi" do @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0']) end end -end
\ No newline at end of file +end |