Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix idempotency for empty environment #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet/provider/cron/crontab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def self.prefetch_hook(records)
record[:unmanaged] = true
end
if envs.nil? || envs.empty?
record[:environment] = :absent
record[:environment] = []
else
# Collect all of the environment lines, and mark the records to be skipped,
# since their data is included in our crontab record.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
compatible_agents.each do |agent|
it "ensures idempotency on #{agent}" do
step 'Cron: basic - verify that it can be created'
result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}')
result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present, environment => [],}')
expect(result.stdout).to match(%r{ensure: created})

result = run_cron_on(agent, :list, 'tstuser')
expect(result.stdout).to match(%r{. . . . . .bin.true})

step 'Cron: basic - should not create again'
result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}')
result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present, environment => [],}')
expect(result.stdout).not_to match(%r{ensure: created})
end
end
Expand Down
Loading