Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(maint) update cron whitespace strip acceptance test
Since f5d2367 leading and trailing whitespace was stripped from the cron command to ensure writing cron entries is idempotent. This made the cron `should_not_rewrite_with_trailing_whitespace.rb` acceptance test meaningless. This commit updates the acceptance test to confirm the fix for #656 and updates the test name to reflect the expected behavior.
- Loading branch information
1 parent
91fa7f1
commit 8ccb4fa
Showing
2 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
25 changes: 0 additions & 25 deletions
25
acceptance/tests/resource/cron/should_not_rewrite_with_trailing_whitespace.rb
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
test_name "(#656) leading and trailing whitespace in cron entries should should be stripped" | ||
confine :except, :platform => 'windows' | ||
|
||
require 'puppet/acceptance/common_utils' | ||
extend Puppet::Acceptance::CronUtils | ||
|
||
agents.each do |host| | ||
step "create user account for testing cron entries" | ||
setup host | ||
teardown do | ||
step "tear down user account for cron entries" | ||
clean host | ||
end | ||
|
||
step "apply the resource on the host using puppet resource" | ||
on(host, puppet_resource("cron", "crontest", "user=tstuser", "command=' date > /dev/null '", "ensure=present")) do | ||
assert_match(/created/, stdout, "Did not create crontab for tstuser on #{host}") | ||
end | ||
|
||
step "verify the added crontab entry has stripped whitespace" | ||
run_cron_on(host, :list, 'tstuser') do | ||
assert_match(/\* \* \* \* \* date > .dev.null/, stdout, "Incorrect crontab for tstuser on #{host}") | ||
end | ||
|
||
step "apply the resource with trailing whitespace and check nothing happened" | ||
on(host, puppet_resource("cron", "crontest", "user=tstuser", "command='date > /dev/null '", "ensure=present")) do | ||
assert_no_match(/ensure: created/, stdout, "Rewrote the line with trailing space in crontab for tstuser on #{host}") | ||
end | ||
|
||
step "apply the resource with leading whitespace and check nothing happened" | ||
on(host, puppet_resource("cron", "crontest", "user=tstuser", "command=' date > /dev/null'", "ensure=present")) do | ||
assert_no_match(/ensure: created/, stdout, "Rewrote the line with trailing space in crontab for tstuser on #{host}") | ||
end | ||
end |