summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2016-01-13 14:44:51 -0800
committerMatt Wrock <matt@mattwrock.com>2016-01-14 12:14:24 -0800
commitdd42bd9e51aab845e3be980a3a130382adeee1e4 (patch)
tree072955dee8069e03a51aa3bd94c120f062aa4724
parent1d26aaa3c2eb663b002f144568017a6aa1925013 (diff)
downloadchef-choco_func_tests.tar.gz
adding functional tests for chocolatey providerchoco_func_tests
-rw-r--r--spec/functional/assets/chocolatey_feed/test-A.1.5.nupkgbin0 -> 2669 bytes
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb25
2 files changed, 19 insertions, 6 deletions
diff --git a/spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg b/spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg
new file mode 100644
index 0000000000..9ce9445689
--- /dev/null
+++ b/spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg
Binary files differ
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index 406ebcd184..f8df129c6e 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -50,7 +50,8 @@ ConEmu|15.10.25.0
remote_list_stdout = <<-EOF
chocolatey|0.9.9.11
ConEmu|15.10.25.1
-git|2.6.2
+Git|2.6.1
+Git|2.6.2
munin-node|1.6.1.20130823
EOF
remote_list_obj = double(stdout: remote_list_stdout)
@@ -68,11 +69,23 @@ munin-node|1.6.1.20130823
end
describe "#candidate_version" do
- it "should set the candidate_version correctly" do
+ it "should set the candidate_version to the latest version when not pinning" do
allow_remote_list(["git"])
expect(provider.candidate_version).to eql(["2.6.2"])
end
+ it "should set the candidate_version to pinned version if available" do
+ allow_remote_list(["git"])
+ new_resource.version('2.6.1')
+ expect(provider.candidate_version).to eql(["2.6.1"])
+ end
+
+ it "should set the candidate_version to nill if pinning to bogus version" do
+ allow_remote_list(["git"])
+ new_resource.version('2.5.0')
+ expect(provider.candidate_version).to eql([nil])
+ end
+
it "should set the candidate_version to nil if there is no candidate" do
allow_remote_list(["vim"])
new_resource.package_name("vim")
@@ -209,7 +222,7 @@ munin-node|1.6.1.20130823
new_resource.package_name("ConEmu")
new_resource.version("15.10.25.1")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 ConEmu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -222,7 +235,7 @@ munin-node|1.6.1.20130823
new_resource.package_name(["chocolatey", "ConEmu"])
new_resource.version([nil, "15.10.25.1"])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 ConEmu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
end
@@ -242,7 +255,7 @@ munin-node|1.6.1.20130823
new_resource.package_name(["ConEmu", "git"])
new_resource.version(["15.10.25.1", nil])
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 ConEmu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -version 15.10.25.1 conemu", {:timeout=>timeout}).and_return(double)
expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", {:timeout=>timeout}).and_return(double)
provider.run_action(:install)
expect(new_resource).to be_updated_by_last_action
@@ -323,7 +336,7 @@ munin-node|1.6.1.20130823
allow_remote_list(["ConEmu"])
new_resource.package_name("ConEmu")
provider.load_current_resource
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y ConEmu", {:timeout=>timeout}).and_return(double)
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", {:timeout=>timeout}).and_return(double)
provider.run_action(:upgrade)
expect(new_resource).to be_updated_by_last_action
end