diff options
author | Thom May <thom@may.lt> | 2017-02-01 18:58:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-01 18:58:11 +0000 |
commit | 301c9ee3e7f027809250e09d9598a8b7c5cbe899 (patch) | |
tree | e1cd7bef3e0496b4d43615a5a2d78e4105229e65 | |
parent | f02de3d8c6769dfb50f1a9429d71d007254d7572 (diff) | |
parent | 6401bccfea219f6a80d6eea58dfe0187fa755ce0 (diff) | |
download | chef-301c9ee3e7f027809250e09d9598a8b7c5cbe899.tar.gz |
Merge pull request #5773 from chef/tduffield/COOL-464/raise-error-if-install-fails
Raise error if ips_package install returns non-zero
-rw-r--r-- | lib/chef/provider/package/ips.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/package/ips_spec.rb | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb index 85053d47f2..bc5b9fff77 100644 --- a/lib/chef/provider/package/ips.rb +++ b/lib/chef/provider/package/ips.rb @@ -74,7 +74,7 @@ class Chef else normal_command end - shell_out_with_timeout(command) + shell_out_with_timeout!(command) end def upgrade_package(name, version) diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb index f47385da09..0dc433b518 100644 --- a/spec/unit/provider/package/ips_spec.rb +++ b/spec/unit/provider/package/ips_spec.rb @@ -122,16 +122,22 @@ INSTALLED context "when installing a package" do it "should run pkg install with the package name and version" do - expect(@provider).to receive(:shell_out).with("pkg install -q crypto/gnupg@2.0.17", timeout: 900) + expect(@provider).to receive(:shell_out!).with("pkg install -q crypto/gnupg@2.0.17", timeout: 900).and_return(local_output) @provider.install_package("crypto/gnupg", "2.0.17") end it "should run pkg install with the package name and version and options if specified" do - expect(@provider).to receive(:shell_out).with("pkg --no-refresh install -q crypto/gnupg@2.0.17", timeout: 900) + expect(@provider).to receive(:shell_out!).with("pkg --no-refresh install -q crypto/gnupg@2.0.17", timeout: 900).and_return(local_output) allow(@new_resource).to receive(:options).and_return("--no-refresh") @provider.install_package("crypto/gnupg", "2.0.17") end + it "raises an error if package fails to install" do + expect(@provider).to receive(:shell_out!).with("pkg --no-refresh install -q crypto/gnupg@2.0.17", timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed) + allow(@new_resource).to receive(:options).and_return("--no-refresh") + expect { @provider.install_package("crypto/gnupg", "2.0.17") }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) + end + it "should not include the human-readable version in the candidate_version" do remote = remote_output remote.stdout = <<-PKG_STATUS @@ -199,7 +205,7 @@ REMOTE end it "should run pkg install with the --accept flag" do - expect(@provider).to receive(:shell_out).with("pkg install -q --accept crypto/gnupg@2.0.17", timeout: 900) + expect(@provider).to receive(:shell_out).with("pkg install -q --accept crypto/gnupg@2.0.17", timeout: 900).and_return(local_output) @provider.install_package("crypto/gnupg", "2.0.17") end end @@ -207,7 +213,7 @@ REMOTE context "when upgrading a package" do it "should run pkg install with the package name and version" do - expect(@provider).to receive(:shell_out).with("pkg install -q crypto/gnupg@2.0.17", timeout: 900) + expect(@provider).to receive(:shell_out).with("pkg install -q crypto/gnupg@2.0.17", timeout: 900).and_return(local_output) @provider.upgrade_package("crypto/gnupg", "2.0.17") end end |