Skip to content
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
6 changes: 3 additions & 3 deletions spec/unit/provider/cron/parsed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
expect(parameters[0][:special]).to eq(:absent)
expect(parameters[0][:command]).to match(%r{\$HOME/bin/daily.job >> \$HOME/tmp/out 2>&1})
expect(parameters[0][:ensure]).to eq(:present)
expect(parameters[0][:environment]).to eq(:absent)
expect(parameters[0][:environment]).to eq([])
expect(parameters[0][:user]).to eq(:absent)

expect(parameters[1][:name]).to match(%r{unmanaged:\$HOME/bin/monthly-\d+})
Expand All @@ -235,7 +235,7 @@
expect(parameters[1][:special]).to eq(:absent)
expect(parameters[1][:command]).to match(%r{\$HOME/bin/monthly})
expect(parameters[1][:ensure]).to eq(:present)
expect(parameters[1][:environment]).to eq(:absent)
expect(parameters[1][:environment]).to eq([])
expect(parameters[1][:user]).to eq(:absent)
expect(parameters[1][:target]).to eq('foobar')
end
Expand All @@ -259,7 +259,7 @@
special: :absent,
command: '/bin/true',
ensure: :present,
environment: :absent,
environment: [],
user: :absent,
target: 'foobar',
},
Expand Down