summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acceptance/tests/resource/cron/should_create_cron.rb6
-rwxr-xr-xacceptance/tests/resource/cron/should_match_existing.rb15
-rwxr-xr-xacceptance/tests/resource/cron/should_remove_cron.rb8
-rwxr-xr-xacceptance/tests/resource/cron/should_remove_matching.rb5
-rwxr-xr-xacceptance/tests/resource/cron/should_update_existing.rb11
5 files changed, 15 insertions, 30 deletions
diff --git a/acceptance/tests/resource/cron/should_create_cron.rb b/acceptance/tests/resource/cron/should_create_cron.rb
index 5badac05f..d40228070 100644
--- a/acceptance/tests/resource/cron/should_create_cron.rb
+++ b/acceptance/tests/resource/cron/should_create_cron.rb
@@ -13,14 +13,12 @@ agents.each do |host|
step "apply the resource on the host using puppet resource"
on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}",
"command=/bin/true", "ensure=present")) do
- fail_test "didn't notice creation of the cron stuff" unless
- stdout.include? 'created'
+ assert_match(/created/, stdout, "Did not create crontab for #{tmpuser} on #{host}")
end
step "verify that crontab -l contains what you expected"
run_cron_on(host, :list, tmpuser) do
- fail_test "didn't find the command as expected" unless
- stdout.include? "* * * * * /bin/true"
+ assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Incorrect crontab for #{tmpuser} on #{host}")
end
step "remove the crontab file for that user"
diff --git a/acceptance/tests/resource/cron/should_match_existing.rb b/acceptance/tests/resource/cron/should_match_existing.rb
index b5c5d359d..92e7dc2cc 100755
--- a/acceptance/tests/resource/cron/should_match_existing.rb
+++ b/acceptance/tests/resource/cron/should_match_existing.rb
@@ -10,23 +10,18 @@ agents.each do |host|
step "ensure the user exist via puppet"
apply_manifest_on host, create_user
- step "create the existing job by hand..."
+ step "Create the existing cron job by hand..."
run_cron_on(host,:add,tmpuser,"* * * * * /bin/true")
- step "apply the resource on the host using puppet resource"
+ step "Apply the resource on the host using puppet resource"
on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}",
"command=/bin/true", "ensure=present")) do
- # This is a weak/fragile test. The output has changed
- # causing this test to fail erronously. Changed to the correct
- # output to match, but this code should be re-feactored.
- fail_test "didn't see the output we expected..." unless
- stdout.include? 'present'
+ assert_match(/present/, stdout, "Failed creating crontab for #{tmpuser} on #{host}")
end
- step "verify that crontab -l contains what you expected"
+ step "Verify that crontab -l contains what you expected"
run_cron_on(host, :list, tmpuser) do
- fail_test "didn't find the command as expected" unless
- stdout.include? "* * * * * /bin/true"
+ assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Did not find crontab for #{tmpuser} on #{host}")
end
step "remove the crontab file for that user"
diff --git a/acceptance/tests/resource/cron/should_remove_cron.rb b/acceptance/tests/resource/cron/should_remove_cron.rb
index 9956d0d71..d6b8822d6 100755
--- a/acceptance/tests/resource/cron/should_remove_cron.rb
+++ b/acceptance/tests/resource/cron/should_remove_cron.rb
@@ -16,16 +16,12 @@ agents.each do |host|
step "apply the resource on the host using puppet resource"
on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}",
"command=/bin/true", "ensure=absent")) do
- # REVISIT: This is ported from the original test, which seems to me a
- # weak test, but I don't want to improve it now. --daniel 2010-12-23
- fail_test "didn't see the output we expected..." unless
- stdout.include? 'removed'
+ assert_match(/crontest\D+ensure:\s+removed/, stdout, "Didn't remove crobtab entry for #{tmpuser} on #{host}")
end
step "verify that crontab -l contains what you expected"
run_cron_on(host, :list, tmpuser) do
- fail_test "didn't found the command we tried to remove" if
- stdout.include? "/bin/true"
+ assert_match(/\/bin\/true/, stdout, "Error: Found entry for #{tmpuser} on #{host}")
end
step "remove the crontab file for that user"
diff --git a/acceptance/tests/resource/cron/should_remove_matching.rb b/acceptance/tests/resource/cron/should_remove_matching.rb
index f4de0de0c..59042c7a8 100755
--- a/acceptance/tests/resource/cron/should_remove_matching.rb
+++ b/acceptance/tests/resource/cron/should_remove_matching.rb
@@ -15,11 +15,10 @@ agents.each do |host|
step "create the existing job by hand..."
run_cron_on(host,:add,tmpuser,"* * * * * /bin/true")
- step "apply the resource change on the host"
+ step "Remove cron resource"
on(host, puppet_resource("cron", "bogus", "user=#{tmpuser}",
"command=/bin/true", "ensure=absent")) do
- fail_test "didn't see the output we expected..." unless
- stdout.include? 'removed'
+ assert_match(/bogus\D+ensure: removed/, stdout, "Removing cron entry failed for #{tmpuser} on #{host}")
end
step "verify that crontab -l contains what you expected"
diff --git a/acceptance/tests/resource/cron/should_update_existing.rb b/acceptance/tests/resource/cron/should_update_existing.rb
index ff179307f..b37952a63 100755
--- a/acceptance/tests/resource/cron/should_update_existing.rb
+++ b/acceptance/tests/resource/cron/should_update_existing.rb
@@ -15,21 +15,18 @@ agents.each do |host|
step "verify that crontab -l contains what you expected"
run_cron_on(host,:list,tmpuser) do
- fail_test "didn't find the content in the crontab" unless
- stdout.include? '* * * * * /bin/true'
+ assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Didn't find correct crobtab entry for #{tmpuser} on #{host}")
end
step "apply the resource change on the host"
on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}",
- "command=/bin/true", "ensure=present", "hour='0-6'")) do
- fail_test "didn't update the time as expected" unless
- stdout.include? "hour => ['0-6']"
+ "command=/bin/true", "ensure=present", "hour='0-6'")) do
+ assert_match(/hour\s+=>\s+\['0-6'\]/, stdout, "Modifying cron entry failed for #{tmpuser} on #{host}")
end
step "verify that crontab -l contains what you expected"
run_cron_on(host,:list,tmpuser) do
- fail_test "didn't find the content in the crontab" unless
- stdout.include? '* 0-6 * * * /bin/true'
+ assert_match(/\* 0-6 \* \* \* \/bin\/true/, stdout, "Didn't find correctly modified time entry in crobtab entry for #{tmpuser} on #{host}")
end
step "remove the crontab file for that user"