From 268f937120942799e635328ef6e9ae7686b00dfc Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 1 Jul 2016 11:48:59 -0700 Subject: fix candidate version and add unit test --- lib/chef/provider/package/aix.rb | 7 +++++++ spec/unit/provider/package/aix_spec.rb | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb index 97400978db..6bbcdf8218 100644 --- a/lib/chef/provider/package/aix.rb +++ b/lib/chef/provider/package/aix.rb @@ -102,6 +102,9 @@ class Chef @candidate_version = candidate new_resource.version(candidate) Chef::Log.debug("#{new_resource} setting install candidate version to #{@candidate_version}") + candidate + else + nil end end end @@ -146,6 +149,10 @@ class Chef end ret.stdout.each_line do |line| case line + # installp will return lines with product:file_set:version + # So we are searching for products or filesets that match the package name + # Example line: + # samba.base:samba.base.rte:1.6.0.3::I:C:::::N:Network Authentication Service Client::::0:: when /(^|:)#{new_resource.package_name}:/ fields = line.split(":") file_sets.push([fields[1], fields[2]]) diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb index b6b94d3fe0..95d6cb78e4 100644 --- a/spec/unit/provider/package/aix_spec.rb +++ b/spec/unit/provider/package/aix_spec.rb @@ -234,9 +234,11 @@ EOH end it "should lookup the candidate_version if the variable is not already set" do - status = double(:stdout => "", :exitstatus => 0) + bffinfo = "/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX: + /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:" + status = double(:stdout => bffinfo, :exitstatus => 0) expect(@provider).to receive(:shell_out).and_return(status) - @provider.candidate_version + expect(@provider.candidate_version).to eq("3.3.12.0") end it "should throw and exception if the exitstatus is not 0" do -- cgit v1.2.1