diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-05-03 15:28:37 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-05-03 15:28:37 -0700 |
commit | 4282d67d1f44d374e932c3916e41bd37c9df907a (patch) | |
tree | 6f3260e516c84e04b3b90c279245d71f021c820a | |
parent | fdc03486ed044c180b8fab3da8a1f0e5f0dab097 (diff) | |
download | chef-4282d67d1f44d374e932c3916e41bd37c9df907a.tar.gz |
add check for passing nil candidate_version to superclass
-rw-r--r-- | lib/chef/provider/package/apt.rb | 3 | ||||
-rw-r--r-- | spec/unit/provider/package/apt_spec.rb | 24 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb index 020273ed12..8b0985e736 100644 --- a/lib/chef/provider/package/apt.rb +++ b/lib/chef/provider/package/apt.rb @@ -113,9 +113,6 @@ class Chef "-o APT::Default-Release=#{new_resource.default_release}" if new_resource.respond_to?(:default_release) && new_resource.default_release end - # FIXME: need spec to check that candidate_version is set correctly on a virtual package - # FIXME: need spec to check that packages missing a candidate_version can be removed/purged - def resolve_package_versions(pkg) current_version = nil candidate_version = nil diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index 98d2b8d524..e9eaa2c70e 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -83,6 +83,30 @@ sudo: expect(@provider.candidate_version).to eql(["1.7.2p1-1ubuntu5.3"]) end + # it is the superclasses responsibility to throw most exceptions + it "if the package does not exist in the cache sets installed + candidate version to nil" do + @new_resource.package_name("conic-smarms") + policy_out = <<-POLICY_STDOUT +N: Unable to locate package conic-smarms + POLICY_STDOUT + policy = double(:stdout => policy_out, :exitstatus => 0) + expect(@provider).to receive(:shell_out!).with( + "apt-cache policy conic-smarms", + :env => { "DEBIAN_FRONTEND" => "noninteractive" }, + :timeout => @timeout + ).and_return(policy) + showpkg_out = <<-SHOWPKG_STDOUT +N: Unable to locate package conic-smarms + SHOWPKG_STDOUT + showpkg = double(:stdout => showpkg_out, :exitstatus => 0) + expect(@provider).to receive(:shell_out!).with( + "apt-cache showpkg conic-smarms", + :env => { "DEBIAN_FRONTEND" => "noninteractive" }, + :timeout => @timeout + ).and_return(showpkg) + @provider.load_current_resource + end + # libmysqlclient-dev is a real package in newer versions of debian + ubuntu # list of virtual packages: http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt it "should not install the virtual package there is a single provider package and it is installed" do |