diff options
author | AbhishekKr <abhikumar163@gmail.com> | 2016-07-31 07:42:10 +0530 |
---|---|---|
committer | AbhishekKr <abhikumar163@gmail.com> | 2016-07-31 07:42:10 +0530 |
commit | c3c6cfc156d0a0bfe7c7dd4f273a2c2bdc4b0281 (patch) | |
tree | cafccae761432edd05c952f5c8fdb452bfd30ad5 /spec/unit/provider | |
parent | 58e147a9dfa331c359df2c9a2bcc53a27a722ef5 (diff) | |
parent | 6b88d8c1bd89f9864478fc873352c2881441dbfe (diff) | |
download | chef-c3c6cfc156d0a0bfe7c7dd4f273a2c2bdc4b0281.tar.gz |
Merge branch 'master' of https://github.com/chef/chef
Diffstat (limited to 'spec/unit/provider')
-rw-r--r-- | spec/unit/provider/package/aix_spec.rb | 13 | ||||
-rw-r--r-- | spec/unit/provider/package/zypper_spec.rb | 20 | ||||
-rw-r--r-- | spec/unit/provider/powershell_script_spec.rb | 8 |
3 files changed, 35 insertions, 6 deletions
diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb index 6940874a43..2b574bb7df 100644 --- a/spec/unit/provider/package/aix_spec.rb +++ b/spec/unit/provider/package/aix_spec.rb @@ -73,6 +73,19 @@ describe Chef::Provider::Package::Aix do expect(@new_resource.version).to eq("3.3.12.0") end + it "should warn if the package is not a fileset" do + info = "samba.base:samba.base.samples:3.3.12.0::COMMITTED:I:Samba for AIX: + /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:" + status = double("Status", :stdout => info, :exitstatus => 0) + expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base", timeout: 900).and_return(status) + expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base", timeout: 900).and_return(@empty_status) + expect(Chef::Log).to receive(:warn).once.with(%r{bff package by product name}) + @provider.load_current_resource + + expect(@provider.current_resource.package_name).to eq("samba.base") + expect(@new_resource.version).to eq("3.3.12.0") + end + it "should return the current version installed if found by lslpp" do status = double("Status", :stdout => @bffinfo, :exitstatus => 0) @stdout = StringIO.new(@bffinfo) diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index df0a1da9a2..8838c26b71 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -72,7 +72,7 @@ describe Chef::Provider::Package::Zypper do provider.load_current_resource end - it "should set the installed version if zypper info has one" do + it "should set the installed version if zypper info has one (zypper version < 1.13.0)" do status = double(:stdout => "Version: 1.0\nInstalled: Yes\n", :exitstatus => 0) allow(provider).to receive(:shell_out!).and_return(status) @@ -80,7 +80,15 @@ describe Chef::Provider::Package::Zypper do provider.load_current_resource end - it "should set the candidate version if zypper info has one" do + it "should set the installed version if zypper info has one (zypper version >= 1.13.0)" do + status = double(:stdout => "Version : 1.0 \nInstalled : Yes \n", :exitstatus => 0) + + allow(provider).to receive(:shell_out!).and_return(status) + expect(current_resource).to receive(:version).with(["1.0"]).and_return(true) + provider.load_current_resource + end + + it "should set the candidate version if zypper info has one (zypper version < 1.13.0)" do status = double(:stdout => "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", :exitstatus => 0) allow(provider).to receive(:shell_out!).and_return(status) @@ -88,6 +96,14 @@ describe Chef::Provider::Package::Zypper do expect(provider.candidate_version).to eql(["1.0"]) end + it "should set the candidate version if zypper info has one (zypper version >= 1.13.0)" do + status = double(:stdout => "Version : 1.0 \nInstalled : No \nStatus : out-of-date (version 0.9 installed)", :exitstatus => 0) + + allow(provider).to receive(:shell_out!).and_return(status) + provider.load_current_resource + expect(provider.candidate_version).to eql(["1.0"]) + end + it "should return the current resouce" do expect(provider.load_current_resource).to eql(current_resource) end diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index 5b5c783986..96869ff31c 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -43,8 +43,8 @@ describe Chef::Provider::PowershellScript, "action_run" do allow(Chef::Platform).to receive(:windows_nano_server?).and_return(true) allow(provider).to receive(:is_forced_32bit).and_return(false) os_info_double = double("os_info") - allow(provider.run_context.node.kernel).to receive(:os_info).and_return(os_info_double) - allow(os_info_double).to receive(:system_directory).and_return("C:\\Windows\\system32") + allow(provider.run_context.node["kernel"]).to receive(:[]).with("os_info").and_return(os_info_double) + allow(os_info_double).to receive(:[]).with("system_directory").and_return("C:\\Windows\\system32") end it "sets the -Command flag as the last flag" do @@ -58,8 +58,8 @@ describe Chef::Provider::PowershellScript, "action_run" do allow(Chef::Platform).to receive(:windows_nano_server?).and_return(false) allow(provider).to receive(:is_forced_32bit).and_return(false) os_info_double = double("os_info") - allow(provider.run_context.node.kernel).to receive(:os_info).and_return(os_info_double) - allow(os_info_double).to receive(:system_directory).and_return("C:\\Windows\\system32") + allow(provider.run_context.node["kernel"]).to receive(:[]).with("os_info").and_return(os_info_double) + allow(os_info_double).to receive(:[]).with("system_directory").and_return("C:\\Windows\\system32") end it "sets the -File flag as the last flag" do |