summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-12-08 13:52:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-12-08 13:52:00 -0800
commit6d383c9c6a47db7ffc02a9769d7d0e0db273f8d6 (patch)
tree20ad858b489de7efde2a43a83cc7673fb8b34c7c
parentf4eb596aff4bc972957b318c30bcf1960eb7b8c1 (diff)
parent5ff5f6f4779d622f9183d3b5d9bc1d6a4fcd0444 (diff)
downloadchef-6d383c9c6a47db7ffc02a9769d7d0e0db273f8d6.tar.gz
Merge pull request #4258 from chef/jdm/dpkg-spec-fixes
Fix dpkg specs to run on debian 6
-rw-r--r--spec/functional/resource/dpkg_package_spec.rb47
1 files changed, 25 insertions, 22 deletions
diff --git a/spec/functional/resource/dpkg_package_spec.rb b/spec/functional/resource/dpkg_package_spec.rb
index b0e2a5ca6c..aebe2475a5 100644
--- a/spec/functional/resource/dpkg_package_spec.rb
+++ b/spec/functional/resource/dpkg_package_spec.rb
@@ -45,11 +45,15 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.package_name name
end
- def should_be_purged_or_removed(package, action)
- if action == :purge
- shell_out!("dpkg -s #{package}", returns: [1])
+ def should_be_purged_or_removed(package, action=nil)
+ status = shell_out("dpkg -s #{package}")
+ output = status.stdout + status.stderr
+ if action.nil? || action == :purge
+ expect(output).to match(/no info|not-installed|not installed/)
+ elsif action == :remove
+ expect(output).to match(/deinstall ok config-files/)
else
- expect(shell_out("dpkg -s #{package}").stdout).to match(/deinstall ok config-files/)
+ raise "Unknown action"
end
end
@@ -187,13 +191,13 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
shell_out!("dpkg -i #{test1_0}")
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should do nothing if the package is not installed when the name is a source" do
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should remove a package that is installed when the name is the package name and source is nil" do
@@ -201,14 +205,14 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name "chef-integration-test"
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should do nothing if the package is not installed when the name is the package name and the source is nil" do
set_dpkg_package_name "chef-integration-test"
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should remove a package that is installed when the name is changed but the source is a package" do
@@ -217,7 +221,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.source test1_0
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should do nothing if the package is not installed when the name is changed but the source is a package" do
@@ -225,7 +229,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.source test1_0
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should remove a package if the name is a file that does not exist, but the source exists" do
@@ -235,7 +239,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.source test1_0
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should do nothing if the package is not installed when the name is a file that does not exist, but the source exists" do
@@ -245,7 +249,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.source test1_0
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should remove a package if the package_name is correct, but the source does not exist" do
@@ -255,7 +259,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.source File.join(test1_0, "make.it.fail")
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- shell_out!('dpkg -s chef-integration-test', returns: [1])
+ should_be_purged_or_removed('chef-integration-test')
end
it "should do nothing if the package_name is correct, but the source does not exist, and the package is not installed" do
@@ -264,7 +268,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
dpkg_package.source File.join(test1_0, "make.it.fail")
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test')
end
it "should remove both packages when called with two" do
@@ -272,7 +276,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ]
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- shell_out!('dpkg -s chef-integration-test', returns: [1])
+ should_be_purged_or_removed('chef-integration-test')
should_be_purged_or_removed('chef-integration-test2', action)
end
@@ -281,8 +285,8 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ]
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- shell_out!('dpkg -s chef-integration-test', returns: [1])
- shell_out!('dpkg -s chef-integration-test2', returns: [1])
+ should_be_purged_or_removed('chef-integration-test')
+ should_be_purged_or_removed('chef-integration-test2')
end
it "should remove a package when only the second one is installed" do
@@ -290,7 +294,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ]
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- shell_out!('dpkg -s chef-integration-test', returns: [1])
+ should_be_purged_or_removed('chef-integration-test')
should_be_purged_or_removed('chef-integration-test2', action)
end
@@ -298,10 +302,9 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ]
dpkg_package.run_action(action)
expect(dpkg_package).not_to be_updated_by_last_action
- shell_out!('dpkg -s chef-integration-test', returns: [1])
- shell_out!('dpkg -s chef-integration-test2', returns: [1])
+ should_be_purged_or_removed('chef-integration-test')
+ should_be_purged_or_removed('chef-integration-test2')
end
-
end
context "action :remove" do
@@ -330,7 +333,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch:
set_dpkg_package_name "chef-integration-test2"
dpkg_package.run_action(action)
expect(dpkg_package).to be_updated_by_last_action
- expect(shell_out('dpkg -s chef-integration-test2').exitstatus).to eql(1)
+ should_be_purged_or_removed('chef-integration-test2', action)
end
end
end