summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-04-17 14:45:30 -0700
committerTim Smith <tsmith84@gmail.com>2020-04-17 14:45:30 -0700
commit8cb8ebf764ab40900c5a65d48e1e0b97e1d075d5 (patch)
tree3b902d40358d51c01bd6f8800747c0c6fe5570c5 /spec
parent742eca396738c2a21ab4cccb919ea7bb0a5974b7 (diff)
downloadchef-8cb8ebf764ab40900c5a65d48e1e0b97e1d075d5.tar.gz
Properly handle unavailable packages
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/package/homebrew_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb
index ef52597bd6..8e4f754d07 100644
--- a/spec/unit/provider/package/homebrew_spec.rb
+++ b/spec/unit/provider/package/homebrew_spec.rb
@@ -237,6 +237,11 @@ describe Chef::Provider::Package::Homebrew do
allow(provider).to receive(:brew_cmd_output).and_return(brew_cmd_output_data)
expect(provider.brew_info).to have_key("vim")
end
+
+ it "returns nil if brew_cmd_output_data returned empty stdout" do
+ allow(provider).to receive(:brew_cmd_output).and_return("")
+ expect(provider.brew_info).to be_nil
+ end
end
describe "#installed_version" do
@@ -276,6 +281,11 @@ describe Chef::Provider::Package::Homebrew do
allow(provider).to receive(:brew_info).and_return(brew_info_data)
expect(provider.available_version("openssl")).to eql("1.1.1f")
end
+
+ it "returns nil if brew_info returns nil" do
+ allow(provider).to receive(:brew_info).and_return(nil)
+ expect(provider.available_version("foo")).to be_nil
+ end
end
describe "#brew_cmd_output" do