summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-12-01 13:24:32 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-12-13 13:31:50 -0800
commitecfd20c6d27fc0a69a353e14926d59c0a323de92 (patch)
tree0b41ef579e2a044a9dea8484fa85ef43b2936ab9
parente4b841739a2f8e181593f6bd413ebe9e161ef7d6 (diff)
downloadchef-ecfd20c6d27fc0a69a353e14926d59c0a323de92.tar.gz
add tests and deprecation for allow_downgrade
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/deprecated.rb10
-rw-r--r--lib/chef/resource/dnf_package.rb5
-rw-r--r--spec/functional/resource/dnf_package_spec.rb36
3 files changed, 48 insertions, 3 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index 3a988fdfa3..1ab1b416eb 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -186,6 +186,16 @@ class Chef
end
end
+ class DnfPackageAllowDowngrade < Base
+ def id
+ 10
+ end
+
+ def target
+ "dnf_package_allow_downgrade.html"
+ end
+ end
+
class Generic < Base
def url
"https://docs.chef.io/chef_deprecations_client.html"
diff --git a/lib/chef/resource/dnf_package.rb b/lib/chef/resource/dnf_package.rb
index d712e66cc3..e2b89bde7a 100644
--- a/lib/chef/resource/dnf_package.rb
+++ b/lib/chef/resource/dnf_package.rb
@@ -54,8 +54,9 @@ class Chef
end
}
- # FIXME: dnf install should downgrade, so this should warn that users do not need to use it any more?
- property :allow_downgrade, [ true, false ], default: false
+ def allow_downgrade(arg = nil)
+ Chef.deprecated(:dnf_package_allow_downgrade, "the allow_downgrade property on the dnf_package provider is not used, DNF supports downgrades by default.")
+ end
end
end
end
diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb
index 0cc96ce3c2..4e038de01e 100644
--- a/spec/functional/resource/dnf_package_spec.rb
+++ b/spec/functional/resource/dnf_package_spec.rb
@@ -167,7 +167,23 @@ gpgcheck=0
end
end
- context "with allow_downgrade" do
+ context "downgrades" do
+ it "just work with DNF" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "throws a deprecation warning with allow_downgrade" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ dnf_package.allow_downgrade true
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
end
context "with arch property" do
@@ -225,6 +241,24 @@ gpgcheck=0
end
describe ":upgrade" do
+ context "downgrades" do
+ it "just work with DNF" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "throws a deprecation warning with allow_downgrade" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ dnf_package.allow_downgrade true
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+ end
end
describe ":remove" do