summaryrefslogtreecommitdiff
path: root/spec/unit/provider
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2016-01-12 09:58:40 -0800
committerMatt Wrock <matt@mattwrock.com>2016-01-12 09:58:40 -0800
commit4e2b723f880447874f1fd560fdcf69c466d3ee90 (patch)
tree3bcbe3a7b8ee5f55d4371102296e7273db7c9455 /spec/unit/provider
parent163dac577fd4d867696e6959cd5dc6d996fd6798 (diff)
parent7f32905c7b5600de2004f83bf4f05053db2b3b12 (diff)
downloadchef-4e2b723f880447874f1fd560fdcf69c466d3ee90.tar.gz
Merge pull request #4378 from chef/choco_edits
assert candidates exist for alternate sources and when pinning versions
Diffstat (limited to 'spec/unit/provider')
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index d2d6fabb19..b2e1d2daaf 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -54,7 +54,7 @@ git|2.6.2
munin-node|1.6.1.20130823
EOF
remote_list_obj = double(stdout: remote_list_stdout)
- allow(provider).to receive(:shell_out!).with("#{choco_exe} list -r #{package_names.join ' '}#{args}", {timeout: timeout}).and_return(remote_list_obj)
+ allow(provider).to receive(:shell_out!).with("#{choco_exe} list -ar #{package_names.join ' '}#{args}", {timeout: timeout}).and_return(remote_list_obj)
end
describe "#initialize" do
@@ -284,12 +284,30 @@ munin-node|1.6.1.20130823
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
+ it "installing a package version that does not exist throws an error" do
+ allow_remote_list(["git"])
+ new_resource.package_name("git")
+ new_resource.version("2.7.0")
+ provider.load_current_resource
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
+ end
+
it "installing multiple packages with a package that does not exist throws an error" do
allow_remote_list(["git", "package-does-not-exist"])
new_resource.package_name(["git", "package-does-not-exist"])
provider.load_current_resource
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
end
+
+ context "alternate source" do
+ it "installing a package that does not exist throws an error" do
+ allow_remote_list(["package-does-not-exist"], " -source alternate_source")
+ new_resource.package_name("package-does-not-exist")
+ new_resource.source("alternate_source")
+ provider.load_current_resource
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
+ end
+ end
end
describe "#action_upgrade" do
@@ -330,9 +348,9 @@ munin-node|1.6.1.20130823
it "version pins work as well" do
allow_remote_list(["git"])
- new_resource.version("99.99.99.99")
+ new_resource.version("2.6.2")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y -version 99.99.99.99 git", {:timeout=>timeout})
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y -version 2.6.2 git", {:timeout=>timeout})
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end
@@ -358,6 +376,16 @@ munin-node|1.6.1.20130823
provider.load_current_resource
expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
end
+
+ context "alternate source" do
+ it "installing a package that does not exist throws an error" do
+ allow_remote_list(["package-does-not-exist"], " -source alternate_source")
+ new_resource.package_name("package-does-not-exist")
+ new_resource.source("alternate_source")
+ provider.load_current_resource
+ expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
+ end
+ end
end
describe "#action_remove" do