summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-12-09 12:40:14 -0800
committerTim Smith <tsmith84@gmail.com>2021-01-04 17:17:49 -0800
commit71d0091a6c757db267cdd6738be0ca265dc0c4d0 (patch)
treeab224bc7902bbf2623e7ced94c2e6c97b850b647 /spec/functional
parent2398e9cab41feaec9556ee9d160642f5d90acf05 (diff)
downloadchef-71d0091a6c757db267cdd6738be0ca265dc0c4d0.tar.gz
Fix idempotency and parsing issues with DNF installs
Fixes issues with exceptions raising exceptions as well. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/resource/dnf_package_spec.rb335
1 files changed, 319 insertions, 16 deletions
diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb
index eef0d6296b..cd107c5843 100644
--- a/spec/functional/resource/dnf_package_spec.rb
+++ b/spec/functional/resource/dnf_package_spec.rb
@@ -91,7 +91,6 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be false
- 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 install twice" do
@@ -128,6 +127,105 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
end
end
+ context "expanded idempotency checks with version variants" do
+ %w{1.10 1* 1.10-1 1*-1 1.10-* 1*-* 0:1.10 0:1* 0:1.10-1 0:1*-1 *:1.10-* *:1*-*}.each do |vstring|
+ it "installs the rpm when #{vstring} is in the package_name" do
+ flush_cache
+ dnf_package.package_name("chef_rpm-#{vstring}")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ end
+
+ it "is idempotent when #{vstring} is in the package_name" do
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm-#{vstring}")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "installs the rpm when #{vstring} is in the version property" do
+ flush_cache
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version(vstring)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ end
+
+ it "is idempotent when #{vstring} is in the version property" do
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version(vstring)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "upgrades the rpm when #{vstring} is in the package_name" do
+ flush_cache
+ dnf_package.package_name("chef_rpm-#{vstring}")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ end
+
+ it "is idempotent when #{vstring} is in the package_name" do
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm-#{vstring}")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "upgrades the rpm when #{vstring} is in the version property" do
+ flush_cache
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version(vstring)
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ end
+
+ it "is idempotent when #{vstring} is in the version property" do
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version(vstring)
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+ end
+
+ %w{1.2 1* 1.2-1 1*-1 1.2-* 1*-* 0:1.2 0:1* 0:1.2-1 0:1*-1 *:1.2-* *:1*-*}.each do |vstring|
+ it "is idempotent when #{vstring} is in the version property and there is a candidate version" do
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version(vstring)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ end
+ end
+
+ %w{1.2 1.2-1 1.2-* 0:1.2 0:1.2-1 *:1.2-*}.each do |vstring|
+ it "is idempotent when #{vstring} is in the version property on upgrade and it doesn't match the candidate version" do
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version(vstring)
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ end
+ end
+
+ %w{1* 1*-1 1*-* 0:1* 0:1*-1 *:1*-*}.each do |vstring|
+ it "upgrades when #{vstring} is in the version property on upgrade and it matches the candidate version" do
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version(vstring)
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+ end
+ end
+
context "with versions or globs in the name" do
it "works with a version" do
flush_cache
@@ -135,6 +233,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "works with an older version" do
@@ -143,6 +243,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "works with an evra" do
@@ -151,6 +253,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "works with version and release" do
@@ -159,6 +263,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "works with a version glob" do
@@ -167,6 +273,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "works with a name glob + version glob" do
@@ -175,6 +283,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "upgrades when the installed version does not match the version string" do
@@ -183,6 +293,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "downgrades when the installed version is higher than the package_name version" do
@@ -191,6 +303,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -203,6 +317,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "matches with a glob" do
@@ -212,6 +328,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "matches the vr" do
@@ -221,6 +339,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "matches the evr" do
@@ -230,6 +350,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "matches with a vr glob", :rhel_gte_8 do
@@ -239,6 +361,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "matches with an evr glob", :rhel_gte_8 do
@@ -248,6 +372,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -260,6 +386,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -270,6 +398,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "installs with 32-bit arch in the name" do
@@ -278,6 +408,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "installs with 64-bit arch in the property" do
@@ -287,6 +419,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "installs with 32-bit arch in the property" do
@@ -296,6 +430,30 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "installs when the 32-bit arch is in the name and the version is in the property" do
+ flush_cache
+ dnf_package.package_name("chef_rpm.i686")
+ dnf_package.version("1.10-1")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "installs when the 64-bit arch is in the name and the version is in the property" do
+ flush_cache
+ dnf_package.package_name("chef_rpm.#{pkg_arch}")
+ dnf_package.version("1.10-1")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -306,6 +464,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "when it is met, it does nothing" do
@@ -330,6 +490,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "when it is not met by an installed rpm, it upgrades" do
@@ -338,6 +500,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with an equality constraint, when it is not met by an installed rpm, it upgrades" do
@@ -346,6 +510,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with an equality constraint, when it is met by an installed rpm, it does nothing" do
@@ -382,6 +548,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with a less than constraint, when the install version matches, it does nothing" do
@@ -398,6 +566,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -424,6 +594,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "installs the package when the name is a path to a file" do
@@ -432,6 +604,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "downgrade on a local file with allow_downgrade true works" do
@@ -441,6 +615,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "does not downgrade the package with :install" do
@@ -475,15 +651,6 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(dnf_package.updated_by_last_action?).to be false
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
end
-
- it "is idempotent when the package is already installed and there is a version string with arch" do
- preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
- dnf_package.version "1.2-1.#{pkg_arch}"
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
- end
end
context "with no available version" do
@@ -502,6 +669,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -513,6 +682,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "does nothing if both are installed" do
@@ -530,6 +701,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "installs the first rpm if the second is installed" do
@@ -539,6 +712,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -550,6 +725,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -561,6 +738,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -572,6 +751,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -597,6 +778,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "should work to enable a disabled repo" do
@@ -608,6 +791,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "when an idempotent install action is run, does not leave repos disabled" do
@@ -628,6 +813,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:install)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
end
@@ -640,6 +827,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
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 match("^chef_rpm-1.2-1.#{pkg_arch}")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "throws a deprecation warning with allow_downgrade" do
@@ -647,10 +836,12 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
expect(Chef).to receive(:deprecated).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.version("1.2")
- dnf_package.run_action(:install)
dnf_package.allow_downgrade true
+ 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 match("^chef_rpm-1.2-1.#{pkg_arch}")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -663,6 +854,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "installs the package when the name is a path to a file" do
@@ -671,6 +864,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "downgrades the package when allow_downgrade is true" do
@@ -679,6 +874,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "upgrades the package" do
@@ -687,6 +884,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "is idempotent when the package is already installed" do
@@ -715,32 +914,104 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
context "version pinning" do
- it "with an equality pin in the name it upgrades a prior package" do
+ it "with a full version pin it installs a later package" do
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
- dnf_package.package_name("chef_rpm-1.10")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version("1.10-1")
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
- it "with a prco equality pin in the name it upgrades a prior package" do
+ it "with a full version pin in the name it downgrdes the package" do
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version("1.2-1")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "with a partial (no release) version pin it installs a later package" do
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
- dnf_package.package_name("chef_rpm = 1.10")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version("1.10")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "with a partial (no release) version pin in the name it downgrdes the package" do
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "with a full version pin it installs a later package" do
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm-1.10-1")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "with a full version pin in the name it downgrdes the package" do
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm-1.2-1")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "with a partial (no release) version pin it installs a later package" do
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm-1.10")
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
- it "with an equality pin in the name it downgrades a later package" do
+ it "with a partial (no release) version pin in the name it downgrdes the package" do
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
dnf_package.package_name("chef_rpm-1.2")
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
+ end
+
+ it "with a prco equality pin in the name it upgrades a prior package" do
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
+ dnf_package.package_name("chef_rpm = 1.10")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with a prco equality pin in the name it downgrades a later package" do
@@ -749,6 +1020,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with a > pin in the name and no rpm installed it installs" do
@@ -757,6 +1030,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with a < pin in the name and no rpm installed it installs" do
@@ -765,6 +1040,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with a > pin in the name and matching rpm installed it does nothing" do
@@ -789,6 +1066,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "with a < pin in the name and non-matching rpm installed it downgrades" do
@@ -797,6 +1076,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:upgrade)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
+ dnf_package.run_action(:upgrade)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
end
@@ -833,6 +1114,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "removes the package if the i686 package is installed", :intel_64bit do
@@ -841,6 +1124,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "removes the package if the prior version i686 package is installed", :intel_64bit do
@@ -849,6 +1134,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -866,6 +1153,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "removes the package if the prior version package is installed" do
@@ -873,6 +1162,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "does nothing if the i686 package is installed" do
@@ -897,6 +1188,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
@@ -907,6 +1200,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
end
@@ -926,6 +1221,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:lock)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
+ dnf_package.run_action(:lock)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "does not lock if its already locked" do
@@ -944,6 +1241,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:unlock)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
+ dnf_package.run_action(:unlock)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "does not unlock an already locked rpm" do
@@ -960,6 +1259,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:lock)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
+ dnf_package.run_action(:lock)
+ expect(dnf_package.updated_by_last_action?).to be false
end
it "check that we can unlock based on provides" do
@@ -969,6 +1270,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
dnf_package.run_action(:unlock)
expect(dnf_package.updated_by_last_action?).to be true
expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
+ dnf_package.run_action(:unlock)
+ expect(dnf_package.updated_by_last_action?).to be false
end
end
end