diff options
author | Tom Duffield <tom@chef.io> | 2017-02-01 10:59:21 -0600 |
---|---|---|
committer | Tom Duffield <tom@chef.io> | 2017-02-01 11:46:23 -0600 |
commit | 6401bccfea219f6a80d6eea58dfe0187fa755ce0 (patch) | |
tree | aa367c1baf1424d0f3c0118a61de6ec6e05d07cd /spec/unit | |
parent | 757b84b0fbb2e835414919a22b5c98c7590ea085 (diff) | |
download | chef-6401bccfea219f6a80d6eea58dfe0187fa755ce0.tar.gz |
Raise error if ips_package install returns non-zerotduffield/COOL-464/raise-error-if-install-fails
Signed-off-by: Tom Duffield <tom@chef.io>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/package/ips_spec.rb | 14 |
1 files changed, 10 insertions, 4 deletions
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 |