diff options
author | Tim Smith <tsmith@chef.io> | 2018-10-26 13:32:58 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-10-28 13:30:43 -0700 |
commit | a7cf7f2ffdd63f816c20233627eca4b724482c91 (patch) | |
tree | 408d5ea0b98132e1244c9ff4387578035f589fcc | |
parent | f343740fbd93812ed9b247b8a7752372ee0ae1fc (diff) | |
download | chef-a7cf7f2ffdd63f816c20233627eca4b724482c91.tar.gz |
Remove deprecated support for FreeBSD pkg providerfreebsd
We continue to support pkgng which shipped in FreeBSD 10.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/provider/package/freebsd/pkg.rb | 114 | ||||
-rw-r--r-- | lib/chef/provider/package/freebsd/port.rb | 6 | ||||
-rw-r--r-- | lib/chef/providers.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource/freebsd_package.rb | 20 | ||||
-rw-r--r-- | spec/unit/provider/package/freebsd/pkg_spec.rb | 274 | ||||
-rw-r--r-- | spec/unit/provider/package/freebsd/pkgng_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/provider/package/freebsd/port_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/resource/freebsd_package_spec.rb | 28 |
8 files changed, 5 insertions, 455 deletions
diff --git a/lib/chef/provider/package/freebsd/pkg.rb b/lib/chef/provider/package/freebsd/pkg.rb deleted file mode 100644 index c847ae5658..0000000000 --- a/lib/chef/provider/package/freebsd/pkg.rb +++ /dev/null @@ -1,114 +0,0 @@ -# -# Authors:: Bryan McLellan (btm@loftninjas.org) -# Matthew Landauer (matthew@openaustralia.org) -# Richard Manyanza (liseki@nyikacraftsmen.com) -# Copyright:: Copyright 2009-2016, Bryan McLellan, Matthew Landauer -# Copyright:: Copyright 2014-2016, Richard Manyanza -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/provider/package/freebsd/base" -require "chef/util/path_helper" - -class Chef - class Provider - class Package - module Freebsd - class Pkg < Base - include PortsHelper - - def install_package(name, version) - unless current_resource.version - case new_resource.source - when /^http/, /^ftp/ - if new_resource.source =~ /\/$/ - shell_out!("pkg_add", "-r", package_name, env: { "PACKAGESITE" => new_resource.source, "LC_ALL" => nil }).status - else - shell_out!("pkg_add", "-r", package_name, env: { "PACKAGEROOT" => new_resource.source, "LC_ALL" => nil }).status - end - logger.trace("#{new_resource} installed from: #{new_resource.source}") - - when /^\// - shell_out!("pkg_add", file_candidate_version_path, env: { "PKG_PATH" => new_resource.source, "LC_ALL" => nil }).status - logger.trace("#{new_resource} installed from: #{new_resource.source}") - - else - shell_out!("pkg_add", "-r", latest_link_name, env: nil).status - end - end - end - - def remove_package(name, version) - shell_out!("pkg_delete", "#{package_name}-#{version || current_resource.version}", env: nil).status - end - - # The name of the package (without the version number) as understood by pkg_add and pkg_info. - def package_name - if supports_ports? - if makefile_variable_value("PKGNAME", port_path) =~ /^(.+)-[^-]+$/ - $1 - else - raise Chef::Exceptions::Package, "Unexpected form for PKGNAME variable in #{port_path}/Makefile" - end - else - new_resource.package_name - end - end - - def latest_link_name - makefile_variable_value("LATEST_LINK", port_path) - end - - def current_installed_version - pkg_info = shell_out!("pkg_info", "-E", "#{package_name}*", env: nil, returns: [0, 1]) - pkg_info.stdout[/^#{Regexp.escape(package_name)}-(.+)/, 1] - end - - def candidate_version - case new_resource.source - when /^http/, /^ftp/ - repo_candidate_version - when /^\// - file_candidate_version - else - ports_candidate_version - end - end - - def file_candidate_version_path - Dir[Chef::Util::PathHelper.escape_glob_dir("#{new_resource.source}/#{current_resource.package_name}") + "*"][-1].to_s - end - - def file_candidate_version - file_candidate_version_path.split(/-/).last.split(/.tbz/).first - end - - def repo_candidate_version - "0.0.0" - end - - def ports_candidate_version - makefile_variable_value("PORTVERSION", port_path) - end - - def port_path - port_dir new_resource.package_name - end - - end - end - end - end -end diff --git a/lib/chef/provider/package/freebsd/port.rb b/lib/chef/provider/package/freebsd/port.rb index 7a46bbaf97..e3174f7d8d 100644 --- a/lib/chef/provider/package/freebsd/port.rb +++ b/lib/chef/provider/package/freebsd/port.rb @@ -34,11 +34,7 @@ class Chef end def current_installed_version - pkg_info = if new_resource.supports_pkgng? - shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70]) - else - shell_out!("pkg_info", "-E", "#{new_resource.package_name}*", env: nil, returns: [0, 1]) - end + pkg_info = shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70]) pkg_info.stdout[/^#{Regexp.escape(new_resource.package_name)}-(.+)/, 1] end diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb index cd265b0618..ac2462c0ca 100644 --- a/lib/chef/providers.rb +++ b/lib/chef/providers.rb @@ -66,7 +66,6 @@ require "chef/provider/package/chocolatey" require "chef/provider/package/dpkg" require "chef/provider/package/dnf" require "chef/provider/package/freebsd/port" -require "chef/provider/package/freebsd/pkg" require "chef/provider/package/freebsd/pkgng" require "chef/provider/package/homebrew" require "chef/provider/package/ips" diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb index f5e4010ee7..0f92d7c229 100644 --- a/lib/chef/resource/freebsd_package.rb +++ b/lib/chef/resource/freebsd_package.rb @@ -20,7 +20,6 @@ require "chef/resource/package" require "chef/provider/package/freebsd/port" -require "chef/provider/package/freebsd/pkg" require "chef/provider/package/freebsd/pkgng" require "chef/mixin/shell_out" @@ -42,30 +41,13 @@ class Chef assign_provider end - # Is the system at least version 1000017 or is the make variable WITH_PKGNG set - # - # @return [Boolean] do we support pkgng - def supports_pkgng? - ships_with_pkgng? || !!shell_out!("make", "-V", "WITH_PKGNG", env: nil).stdout.match(/yes/i) - end - private - # It was not until __FreeBSD_version 1000017 that pkgng became - # the default binary package manager. See '/usr/ports/Mk/bsd.port.mk'. - def ships_with_pkgng? - node[:os_version].to_i >= 1000017 - end - def assign_provider @provider = if source.to_s =~ /^ports$/i Chef::Provider::Package::Freebsd::Port - elsif supports_pkgng? - Chef::Provider::Package::Freebsd::Pkgng else - Chef.deprecated(:freebsd_package_provider, "The freebsd_package provider for pkg (Chef::Provider::Package::Freebsd::Pkg) is deprecated and will be removed from Chef core in 15.0 (April 2019).") - - Chef::Provider::Package::Freebsd::Pkg + Chef::Provider::Package::Freebsd::Pkgng end end end diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb deleted file mode 100644 index 29a8bfef44..0000000000 --- a/spec/unit/provider/package/freebsd/pkg_spec.rb +++ /dev/null @@ -1,274 +0,0 @@ -# -# Authors:: Bryan McLellan (btm@loftninjas.org) -# Matthew Landauer (matthew@openaustralia.org) -# Copyright:: Copyright 2009-2016, Bryan McLellan, Matthew Landauer -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "spec_helper" -require "ostruct" - -describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do - before(:each) do - @node = Chef::Node.new - @events = Chef::EventDispatch::Dispatcher.new - @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Package.new("zsh") - @current_resource = Chef::Resource::Package.new("zsh") - - @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(false) - allow(::File).to receive(:exist?).with("/usr/ports/www/wordpress").and_return(false) - allow(::File).to receive(:exist?).with("www/wordpress").and_return(false) - end - - describe "when determining the current package state" do - before do - allow(@provider).to receive(:ports_candidate_version).and_return("4.3.6") - end - - it "should create a current resource with the name of the new_resource" do - current_resource = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context).current_resource - expect(current_resource.name).to eq("zsh") - end - - it "should return a version if the package is installed" do - expect(@provider).to receive(:current_installed_version).and_return("4.3.6_7") - @provider.load_current_resource - expect(@current_resource.version).to eq("4.3.6_7") - end - - it "should return nil if the package is not installed" do - expect(@provider).to receive(:current_installed_version).and_return(nil) - @provider.load_current_resource - expect(@current_resource.version).to be_nil - end - - it "should return a candidate version if it exists" do - expect(@provider).to receive(:current_installed_version).and_return(nil) - @provider.load_current_resource - expect(@provider.candidate_version).to eql("4.3.6") - end - end - - describe "when querying for package state and properties" do - before do - # @new_resource = Chef::Resource::Package.new("zsh") - - # @provider = Chef::Provider::Package::Freebsd::Pkg.new(@node, @new_resource) - - # @status = double("Status", :exitstatus => 0) - # @stdin = double("STDIN", :null_object => true) - # @stdout = double("STDOUT", :null_object => true) - # @stderr = double("STDERR", :null_object => true) - # @pid = double("PID", :null_object => true) - end - - it "should return the version number when it is installed" do - pkg_info = OpenStruct.new(stdout: "zsh-4.3.6_7") - expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) - allow(@provider).to receive(:package_name).and_return("zsh") - expect(@provider.current_installed_version).to eq("4.3.6_7") - end - - it "does not set the current version number when the package is not installed" do - pkg_info = OpenStruct.new(stdout: "") - expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) - allow(@provider).to receive(:package_name).and_return("zsh") - expect(@provider.current_installed_version).to be_nil - end - - it "should return the port path for a valid port name" do - whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh") - expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) - allow(@provider).to receive(:port_name).and_return("zsh") - expect(@provider.port_path).to eq("/usr/ports/shells/zsh") - end - - # Not happy with the form of these tests as they are far too closely tied to the implementation and so very fragile. - it "should return the ports candidate version when given a valid port path" do - allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") - make_v = OpenStruct.new(stdout: "4.3.6\n", exitstatus: 0) - expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PORTVERSION", { cwd: "/usr/ports/shells/zsh", returns: [0, 1], env: nil, timeout: 900 }).and_return(make_v) - expect(@provider.ports_candidate_version).to eq("4.3.6") - end - - it "should figure out the package name when we have ports" do - allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true) - allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") - make_v = OpenStruct.new(stdout: "zsh-4.3.6_7\n", exitstatus: 0) - expect(@provider).to receive(:shell_out_compacted!).with("make", "-V", "PKGNAME", { cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900 }).and_return(make_v) - # @provider.should_receive(:ports_makefile_variable_value).with("PKGNAME").and_return("zsh-4.3.6_7") - expect(@provider.package_name).to eq("zsh") - end - end - - describe Chef::Provider::Package::Freebsd::Pkg, "install_package" do - before(:each) do - @cmd_result = OpenStruct.new(status: true) - - @provider.current_resource = @current_resource - allow(@provider).to receive(:package_name).and_return("zsh") - allow(@provider).to receive(:latest_link_name).and_return("zsh") - allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") - end - - it "should run pkg_add -r with the package name" do - expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "zsh", env: nil, timeout: 900).and_return(@cmd_result) - @provider.install_package("zsh", "4.3.6_7") - end - end - - describe Chef::Provider::Package::Freebsd::Pkg, "port path" do - before do - # @node = Chef::Node.new - @new_resource = Chef::Resource::Package.new("zsh") - @new_resource.cookbook_name = "adventureclub" - @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) - end - - it "should figure out the port path from the package_name using whereis" do - whereis = OpenStruct.new(stdout: "zsh: /usr/ports/shells/zsh") - expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "zsh", env: nil, timeout: 900).and_return(whereis) - expect(@provider.port_path).to eq("/usr/ports/shells/zsh") - end - - it "should use the package_name as the port path when it starts with /" do - new_resource = Chef::Resource::Package.new("/usr/ports/www/wordpress") - provider = Chef::Provider::Package::Freebsd::Pkg.new(new_resource, @run_context) - expect(provider).not_to receive(:popen4) - expect(provider.port_path).to eq("/usr/ports/www/wordpress") - end - - it "should use the package_name as a relative path from /usr/ports when it contains / but doesn't start with it" do - # @new_resource = double( "Chef::Resource::Package", - # :package_name => "www/wordpress", - # :cookbook_name => "xenoparadox") - new_resource = Chef::Resource::Package.new("www/wordpress") - provider = Chef::Provider::Package::Freebsd::Pkg.new(new_resource, @run_context) - expect(provider).not_to receive(:popen4) - expect(provider.port_path).to eq("/usr/ports/www/wordpress") - end - end - - describe Chef::Provider::Package::Freebsd::Pkg, "ruby-iconv (package with a dash in the name)" do - before(:each) do - @new_resource = Chef::Resource::Package.new("ruby-iconv") - @current_resource = Chef::Resource::Package.new("ruby-iconv") - @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - allow(@provider).to receive(:port_path).and_return("/usr/ports/converters/ruby-iconv") - allow(@provider).to receive(:package_name).and_return("ruby18-iconv") - allow(@provider).to receive(:latest_link_name).and_return("ruby18-iconv") - - @install_result = OpenStruct.new(status: true) - end - - it "should run pkg_add -r with the package name" do - expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "ruby18-iconv", env: nil, timeout: 900).and_return(@install_result) - @provider.install_package("ruby-iconv", "1.0") - end - end - - describe Chef::Provider::Package::Freebsd::Pkg, "remove_package" do - before(:each) do - @pkg_delete = OpenStruct.new(status: true) - @new_resource.version "4.3.6_7" - @current_resource.version "4.3.6_7" - @provider.current_resource = @current_resource - allow(@provider).to receive(:package_name).and_return("zsh") - end - - it "should run pkg_delete with the package name and version" do - expect(@provider).to receive(:shell_out_compacted!).with("pkg_delete", "zsh-4.3.6_7", env: nil, timeout: 900).and_return(@pkg_delete) - @provider.remove_package("zsh", "4.3.6_7") - end - end - - # CHEF-4371 - # There are some port names that contain special characters such as +'s. This breaks the regular expression used to determine what - # version of a package is currently installed and to get the port_path. - # Example package name: bonnie++ - - describe Chef::Provider::Package::Freebsd::Pkg, "bonnie++ (package with a plus in the name :: CHEF-4371)" do - before(:each) do - @new_resource = Chef::Resource::Package.new("bonnie++") - @current_resource = Chef::Resource::Package.new("bonnie++") - @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - end - - it "should return the port path for a valid port name" do - whereis = OpenStruct.new(stdout: "bonnie++: /usr/ports/benchmarks/bonnie++") - expect(@provider).to receive(:shell_out_compacted!).with("whereis", "-s", "bonnie++", env: nil, timeout: 900).and_return(whereis) - allow(@provider).to receive(:port_name).and_return("bonnie++") - expect(@provider.port_path).to eq("/usr/ports/benchmarks/bonnie++") - end - - it "should return the version number when it is installed" do - pkg_info = OpenStruct.new(stdout: "bonnie++-1.96") - expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "bonnie++*", env: nil, returns: [0, 1], timeout: 900).and_return(pkg_info) - allow(@provider).to receive(:package_name).and_return("bonnie++") - expect(@provider.current_installed_version).to eq("1.96") - end - end - - # A couple of examples to show up the difficulty of determining the command to install the binary package given the port: - # PORT DIRECTORY INSTALLED PACKAGE NAME COMMAND TO INSTALL PACKAGE - # /usr/ports/lang/perl5.8 perl-5.8.8_1 pkg_add -r perl - # /usr/ports/databases/mysql50-server mysql-server-5.0.45_1 pkg_add -r mysql50-server - # - # So, in one case it appears the command to install the package can be derived from the name of the port directory and in the - # other case it appears the command can be derived from the package name. Very confusing! - # Well, luckily, after much poking around, I discovered that the two can be disambiguated through the use of the LATEST_LINK - # variable which is set by the ports Makefile - # - # PORT DIRECTORY LATEST_LINK INSTALLED PACKAGE NAME COMMAND TO INSTALL PACKAGE - # /usr/ports/lang/perl5.8 perl perl-5.8.8_1 pkg_add -r perl - # /usr/ports/databases/mysql50-server mysql50-server mysql-server-5.0.45_1 pkg_add -r mysql50-server - # - # The variable LATEST_LINK is named that way because the directory that "pkg_add -r" downloads from is called "Latest" and - # contains the "latest" versions of package as symbolic links to the files in the "All" directory. - - describe Chef::Provider::Package::Freebsd::Pkg, "install_package latest link fixes" do - it "should install the perl binary package with the correct name" do - @new_resource = Chef::Resource::Package.new("perl5.8") - @current_resource = Chef::Resource::Package.new("perl5.8") - @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - allow(@provider).to receive(:package_name).and_return("perl") - allow(@provider).to receive(:latest_link_name).and_return("perl") - - cmd = OpenStruct.new(status: true) - expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "perl", env: nil, timeout: 900).and_return(cmd) - @provider.install_package("perl5.8", "5.8.8_1") - end - - it "should install the mysql50-server binary package with the correct name" do - - @new_resource = Chef::Resource::Package.new("mysql50-server") - @current_resource = Chef::Resource::Package.new("mysql50-server") - @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) - @provider.current_resource = @current_resource - allow(@provider).to receive(:package_name).and_return("mysql-server") - allow(@provider).to receive(:latest_link_name).and_return("mysql50-server") - - cmd = OpenStruct.new(status: true) - expect(@provider).to receive(:shell_out_compacted!).with("pkg_add", "-r", "mysql50-server", env: nil, timeout: 900).and_return(cmd) - @provider.install_package("mysql50-server", "5.0.45_1") - end - end -end diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb index 13e5dd17fd..bc78a178eb 100644 --- a/spec/unit/provider/package/freebsd/pkgng_spec.rb +++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb @@ -62,7 +62,6 @@ describe Chef::Provider::Package::Freebsd::Port do describe "determining current installed version" do before(:each) do - allow(@provider).to receive(:supports_pkgng?) @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\nVersion : 3.1.7\n") end diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb index af5216dc04..069c4e8dec 100644 --- a/spec/unit/provider/package/freebsd/port_spec.rb +++ b/spec/unit/provider/package/freebsd/port_spec.rb @@ -65,23 +65,11 @@ describe Chef::Provider::Package::Freebsd::Port do @pkg_info = OpenStruct.new(stdout: "zsh-3.1.7\n") end - it "should check 'pkg_info' if system uses pkg_* tools" do - allow(@new_resource).to receive(:supports_pkgng?) - expect(@new_resource).to receive(:supports_pkgng?).and_return(false) - expect(@provider).to receive(:shell_out_compacted!).with("pkg_info", "-E", "zsh*", env: nil, returns: [0, 1], timeout: 900).and_return(@pkg_info) + it "should check 'pkg info' to determine the current version" do + expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end - it "should check 'pkg info' if make supports WITH_PKGNG if freebsd version is < 1000017" do - pkg_enabled = OpenStruct.new(stdout: "yes\n") - [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version| - @node.automatic_attrs[:os_version] = freebsd_version - expect(@new_resource).to receive(:shell_out_compacted!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled) - expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) - expect(@provider.current_installed_version).to eq("3.1.7") - end - end - it "should check 'pkg info' if the freebsd version is greater than or equal to 1000017" do freebsd_version = 1000017 @node.automatic_attrs[:os_version] = freebsd_version diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb index 154bd09616..3df1a9c139 100644 --- a/spec/unit/resource/freebsd_package_spec.rb +++ b/spec/unit/resource/freebsd_package_spec.rb @@ -67,37 +67,11 @@ describe Chef::Resource::FreebsdPackage do end end - describe "if freebsd_version is greater than or equal to 1000017" do + describe "if ports is not specified" do it "is Freebsd::Pkgng" do - [1000017, 1000018, 1000500, 1001001, 1100000].each do |freebsd_version| - node.automatic_attrs[:os_version] = freebsd_version - resource.after_created - expect(resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkgng) - end - end - end - - describe "if pkgng enabled" do - it "is Freebsd::Pkgng" do - pkg_enabled = OpenStruct.new(stdout: "yes\n") - allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled) resource.after_created expect(resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkgng) end end - - describe "if freebsd_version is less than 1000017 and pkgng not enabled" do - it "is Freebsd::Pkg" do - pkg_enabled = OpenStruct.new(stdout: "\n") - allow(resource).to receive(:shell_out!).with("make", "-V", "WITH_PKGNG", env: nil).and_return(pkg_enabled) - - [1000016, 1000000, 901503, 902506, 802511].each do |freebsd_version| - node.automatic_attrs[:os_version] = freebsd_version - expect(Chef).to receive(:deprecated).with(:freebsd_package_provider, kind_of(String)) - resource.after_created - expect(resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkg) - end - end - end end end |