diff options
author | Julian C. Dunn <jdunn@chef.io> | 2015-04-29 10:50:31 -0400 |
---|---|---|
committer | Julian C. Dunn <jdunn@chef.io> | 2015-04-29 10:50:31 -0400 |
commit | 411dfbe979082be19a67df4d9d67cc0eb8c93fe2 (patch) | |
tree | fd185efcd506bfc3ac76d0c870e07eef45f893db /spec | |
parent | 672863494394aa7af897c64e0ff63ccfc5f88d9a (diff) | |
download | chef-411dfbe979082be19a67df4d9d67cc0eb8c93fe2.tar.gz |
Fix tests. Add test for source not providing the requested package.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/package/aix_spec.rb | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb index 5bc861b849..bdcc9dc1c3 100644 --- a/spec/unit/provider/package/aix_spec.rb +++ b/spec/unit/provider/package/aix_spec.rb @@ -36,23 +36,27 @@ describe Chef::Provider::Package::Aix do @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("Status", :stdout => "", :exitstatus => 0) + @empty_status = double("Status", :stdout => "", :exitstatus => 0) end it "should create a current resource with the name of new_resource" do - allow(@provider).to receive(:shell_out).and_return(@status) + status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base").and_return(status) + expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base").and_return(@empty_status) @provider.load_current_resource expect(@provider.current_resource.name).to eq("samba.base") end it "should set the current resource bff package name to the new resource bff package name" do - allow(@provider).to receive(:shell_out).and_return(@status) + status = double("Status", :stdout => @bffinfo, :exitstatus => 0) + expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base").and_return(status) + expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base").and_return(@empty_status) @provider.load_current_resource expect(@provider.current_resource.package_name).to eq("samba.base") end it "should raise an exception if a source is supplied but not found" do - allow(@provider).to receive(:shell_out).and_return(@status) + allow(@provider).to receive(:shell_out).and_return(@empty_status) allow(::File).to receive(:exists?).and_return(false) @provider.load_current_resource @provider.define_resource_requirements @@ -62,7 +66,7 @@ describe Chef::Provider::Package::Aix do it "should get the source package version from lslpp if provided" do status = double("Status", :stdout => @bffinfo, :exitstatus => 0) expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base").and_return(status) - expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base").and_return(@status) + expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base").and_return(@empty_status) @provider.load_current_resource expect(@provider.current_resource.package_name).to eq("samba.base") @@ -73,7 +77,7 @@ describe Chef::Provider::Package::Aix do status = double("Status", :stdout => @bffinfo, :exitstatus => 0) @stdout = StringIO.new(@bffinfo) @stdin, @stderr = StringIO.new, StringIO.new - expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base").and_return(@status) + expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base").and_return(status) expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base").and_return(status) @provider.load_current_resource expect(@provider.current_resource.version).to eq("3.3.12.0") @@ -94,12 +98,20 @@ describe Chef::Provider::Package::Aix do end it "should return a current resource with a nil version if the package is not found" do - status = double(:stdout => "", :exitstatus => 0) + status = double("Status", :stdout => @bffinfo, :exitstatus => 0) expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base").and_return(status) - expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base").and_return(status) + expect(@provider).to receive(:shell_out).with("lslpp -lcq samba.base").and_return(@empty_status) @provider.load_current_resource expect(@provider.current_resource.version).to be_nil end + + it "should raise an exception if the source doesn't provide the requested package" do + wrongbffinfo = "/usr/lib/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer: +/etc/objrepos:openssl.base:0.9.8.2400::COMMITTED:I:Open Secure Socket Layer:" + status = double("Status", :stdout => wrongbffinfo, :exitstatus => 0) + expect(@provider).to receive(:shell_out).with("installp -L -d /tmp/samba.base").and_return(status) + expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package) + end end describe "candidate_version" do |