summaryrefslogtreecommitdiff
path: root/spec/unit/provider/package
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2016-01-12 09:06:07 -0800
committerMatt Wrock <matt@mattwrock.com>2016-01-12 09:06:07 -0800
commit7f32905c7b5600de2004f83bf4f05053db2b3b12 (patch)
tree3b4eda21353c637495b4a3912ce4e01a1c84c3b2 /spec/unit/provider/package
parent0944320b72ee1ab16a18a149f5ecb743ace0c0d3 (diff)
downloadchef-7f32905c7b5600de2004f83bf4f05053db2b3b12.tar.gz
assert candidates exist for alternate sources and when pinning versions
Diffstat (limited to 'spec/unit/provider/package')
-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