summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2015-01-16 17:24:15 -0800
committerPhil Dibowitz <phil@ipom.com>2015-02-03 19:32:36 -0800
commit521f7bb7548dc00b626870dec7188dde18870d18 (patch)
tree5cce33359240375ba712a3f0bd8366c7b8cb7940 /lib
parent0665a18112e269b0a8f81ad021cd88af84421fe9 (diff)
downloadchef-521f7bb7548dc00b626870dec7188dde18870d18.tar.gz
Some fixes for package provider, lots of unittests
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/provider/package.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 5c852017cb..58de80c868 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -74,10 +74,10 @@ class Chef
def action_install
# If we specified a version, and it's not the current version, move to the specified version
- if !@new_resource.version.nil? && !(target_version_already_installed?)
+ if new_version_array.any? && !(target_version_already_installed?)
install_version = @new_resource.version
# If it's not installed at all, install it
- elsif @current_resource.version.nil?
+ elsif current_version_array.any? { |x| x.nil? }
install_version = candidate_version
else
Chef::Log.debug("#{@new_resource} is already installed - nothing to do")
@@ -127,13 +127,21 @@ class Chef
end
end
+ def have_any_matching_version?
+ f = []
+ new_version_array.each_with_index do |item, index|
+ f << (item == current_version_array[index])
+ end
+ f.any?
+ end
+
def removing_package?
if !current_version_array.any?
# ! any? means it's all nil's, which means nothing is installed
false
elsif !new_version_array.any?
true # remove any version of all packages
- elsif @new_resource.version == @current_resource.version
+ elsif have_any_matching_version?
true # remove the version we have
else
false # we don't have the version we want to remove
@@ -239,7 +247,7 @@ class Chef
end
def target_version_already_installed?
- @new_resource.version == @current_resource.version
+ new_version_array == current_version_array
end
private