diff options
author | Lamont Granquist <454857+lamont-granquist@users.noreply.github.com> | 2021-11-29 22:28:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-29 22:28:13 -0800 |
commit | 67ad58758853f713388aee6e8437aac6fddc3901 (patch) | |
tree | 28b87c313c6d71b6133a5cd9770c6157f87918b9 /spec | |
parent | f1056e53b346dfe2da5005fd423750977c225a11 (diff) | |
parent | 5496dc736fb28687902daa8a23705c6f234599fa (diff) | |
download | chef-67ad58758853f713388aee6e8437aac6fddc3901.tar.gz |
Merge pull request #12291 from chef/lcg/add-allow-downgrade-to-dnf-package
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/resource/dnf_package_spec.rb | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb index 9e03db5123..35af5d5c1a 100644 --- a/spec/functional/resource/dnf_package_spec.rb +++ b/spec/functional/resource/dnf_package_spec.rb @@ -455,7 +455,7 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do end context "downgrades" do - it "downgrades the package when allow_downgrade" do + it "downgrades the package when allow_downgrade is true" do flush_cache preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm") dnf_package "chef_rpm" do @@ -470,6 +470,18 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do action :install end.should_not_be_updated end + + it "does not downgrade the package when allow_downgrade is false" do + flush_cache + preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm") + dnf_package "chef_rpm" do + options default_options + allow_downgrade false + version "1.2-1" + action :install + end.should_not_be_updated + expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$") + end end context "with arches", :intel_64bit do @@ -763,6 +775,17 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do end.should_not_be_updated end + it "downgrade on a local file with allow_downgrade false does not downgrade" do + preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm") + dnf_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do + options default_options + allow_downgrade false + version "1.2-1" + action :install + end.should_not_be_updated + expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$") + end + it "does not downgrade the package with :install" do preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm") dnf_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do @@ -1027,25 +1050,6 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do action :install end.should_not_be_updated end - - it "throws a deprecation warning with allow_downgrade" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(Chef).to receive(:deprecated).at_least(:once).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/) - preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm") - dnf_package "chef_rpm" do - options default_options - version "1.2" - allow_downgrade true - action :install - end.should_be_updated - expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}") - dnf_package "chef_rpm" do - options default_options - version "1.2" - allow_downgrade true - action :install - end.should_not_be_updated - end end context "with source arguments" do @@ -1092,6 +1096,16 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do end.should_not_be_updated end + it "does not downgrade the package when allow_downgrade is false" do + preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm") + dnf_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do + options default_options + allow_downgrade false + action :upgrade + end.should_not_be_updated + expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$") + end + it "upgrades the package" do preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm") dnf_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm" do |