summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-12-16 11:59:07 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-12-16 11:59:07 -0800
commitb18272eeef335cde79a21a96c4686271dc3d290c (patch)
treeba671de748b30c90246237ee79be118610d03f28
parent3f1f5908b1371676b787b8c390ab3ac0572f3e28 (diff)
downloadchef-b18272eeef335cde79a21a96c4686271dc3d290c.tar.gz
add some idempotency checks
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--spec/functional/resource/dnf_package_spec.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb
index c3e812b2cb..4c9ee6ca97 100644
--- a/spec/functional/resource/dnf_package_spec.rb
+++ b/spec/functional/resource/dnf_package_spec.rb
@@ -61,6 +61,7 @@ gpgcheck=0
describe ":install" do
context "vanilla use case" do
let(:package_name) { "chef_rpm" }
+
it "installs if the package is not installed" do
flush_cache
dnf_package.run_action(:install)
@@ -75,6 +76,16 @@ gpgcheck=0
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
end
+ it "does not install twice" do
+ flush_cache
+ 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.10-1.fc24.x86_64")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
it "does not install if the prior version package is installed" do
preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
dnf_package.run_action(:install)
@@ -568,7 +579,6 @@ gpgcheck=0
let(:package_name) { "chef_rpm" }
it "does nothing if the package is not installed" do
flush_cache
- expect(dnf_package.updated_by_last_action?).to be false
dnf_package.run_action(:remove)
expect(dnf_package.updated_by_last_action?).to be false
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
@@ -581,6 +591,16 @@ gpgcheck=0
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
end
+ it "does not remove the package twice" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
+
it "removes the package if the prior version package is installed" do
preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
dnf_package.run_action(:remove)