summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertagaz <bertagaz@ptitcanardnoir.org>2018-11-19 20:43:52 +0100
committerbertagaz <bertagaz@ptitcanardnoir.org>2018-11-19 20:43:52 +0100
commit6fd72b7f47ec48e628cde4ea2b6155858d1ab4ab (patch)
treee92fa4be571bde76b4799a0c9414940ec307cd60
parentbd529d6f7c253bcfe07ca1d6fa7831ef2b82914f (diff)
Test suite: Factorize out package install/removal.
Refs: #14596
-rw-r--r--features/step_definitions/apt.rb22
-rw-r--r--features/step_definitions/common_steps.rb6
2 files changed, 17 insertions, 11 deletions
diff --git a/features/step_definitions/apt.rb b/features/step_definitions/apt.rb
index bf18941..38bdc4e 100644
--- a/features/step_definitions/apt.rb
+++ b/features/step_definitions/apt.rb
@@ -51,6 +51,12 @@ When /^I update APT using apt$/ do
end
end
+def is_installed?(package)
+ try_for(2*60) do
+ $vm.execute_successfully("dpkg -s '#{package}' 2>/dev/null | grep -qs '^Status:.*installed$'")
+ end
+end
+
Then /^I install "(.+)" using apt$/ do |package|
recovery_proc = Proc.new do
step 'I kill the process "apt"'
@@ -62,22 +68,24 @@ Then /^I install "(.+)" using apt$/ do |package|
"sudo -S DEBIAN_PRIORITY=critical apt -y install #{package}",
:user => LIVE_USER,
:spawn => true)
- try_for(2*60) do
- $vm.execute_successfully("dpkg -s '#{package}' 2>/dev/null | grep -qs '^Status:.*installed$'")
- end
+ is_installed?(package)
end
end
end
+def is_not_installed?(package)
+ try_for(3*60) do
+ state = $vm.execute("apt-cache policy #{package}").stdout.split("\n")[1]
+ /^\s{2}Installed:\s\(none\)$/.match(state) != nil
+ end
+end
+
Then /^I uninstall "(.+)" using apt$/ do |package|
$vm.execute("echo #{@sudo_password} | " +
"sudo -S apt -y remove #{package}",
:user => LIVE_USER,
:spawn => true)
- try_for(3*60) do
- state = $vm.execute("apt-cache policy #{package}").stdout.split("\n")[1]
- /^\s{2}Installed:\s\(none\)$/.match(state) != nil
- end
+ is_not_installed?(package)
end
When /^I configure APT to prefer an old version of cowsay$/ do
diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb
index 0def5b6..dd43e4b 100644
--- a/features/step_definitions/common_steps.rb
+++ b/features/step_definitions/common_steps.rb
@@ -590,14 +590,12 @@ end
Given /^the package "([^"]+)" is( not)? installed( after Additional Software has been started)?$/ do |package, absent, asp|
if absent
- assert($vm.execute("dpkg -s '#{package}' 2>/dev/null").failure?,
- "Package '#{package}' is present in dpkg database")
+ is_not_installed?(package)
else
if asp
step 'the Additional Software installation service has started'
end
- assert($vm.execute("dpkg -s '#{package}' 2>/dev/null | grep -qs '^Status:.*installed$'").success?,
- "Package '#{package}' is not installed")
+ is_installed?(package)
end
end