summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider/package/zypper.rb15
-rw-r--r--spec/functional/resource/zypper_package_spec.rb7
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index d53f4ef6eb..c326a585ca 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -72,12 +72,8 @@ class Chef
end
def candidate_version
- if new_resource.source
- logger.trace("#{new_resource} checking rpm status")
- resolve_source_to_version
-
- else
- @candidate_version ||= package_name_array.each_with_index.map { |pkg, i| available_version(i) }
+ package_name_array.each_with_index.map do |pkg, i|
+ available_version(i).version_with_arch
end
end
@@ -136,7 +132,12 @@ class Chef
def available_version(index)
@available_version ||= []
- @available_version[index] ||= resolve_available_version(package_name_array[index], safe_version_array[index])
+
+ @available_version[index] ||= if new_resource.source
+ resolve_source_to_version
+ else
+ resolve_available_version(package_name_array[index], safe_version_array[index])
+ end
@available_version[index]
end
diff --git a/spec/functional/resource/zypper_package_spec.rb b/spec/functional/resource/zypper_package_spec.rb
index 3d3a1db786..422502a29d 100644
--- a/spec/functional/resource/zypper_package_spec.rb
+++ b/spec/functional/resource/zypper_package_spec.rb
@@ -74,6 +74,13 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
end
+ it "install package with source argument" do
+ source("#{CHEF_SPEC_ASSETS}/zypprepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
+ zypper_package.run_action(:install)
+ expect(zypper_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ end
+
it "does not install if the package is installed" do
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
zypper_package.run_action(:install)