Skip to content

Commit 170dce7

Browse files
authored
Merge pull request #77 from Dan33l/environement_empty_idempotent
fix idempotency for empty environment
2 parents 774df34 + d47a391 commit 170dce7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/puppet/provider/cron/crontab.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def self.prefetch_hook(records)
221221
record[:unmanaged] = true
222222
end
223223
if envs.nil? || envs.empty?
224-
record[:environment] = :absent
224+
record[:environment] = []
225225
else
226226
# Collect all of the environment lines, and mark the records to be skipped,
227227
# since their data is included in our crontab record.

spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
compatible_agents.each do |agent|
1919
it "ensures idempotency on #{agent}" do
2020
step 'Cron: basic - verify that it can be created'
21-
result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}')
21+
result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present, environment => [],}')
2222
expect(result.stdout).to match(%r{ensure: created})
2323

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

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

spec/unit/provider/cron/parsed_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
expect(parameters[0][:special]).to eq(:absent)
224224
expect(parameters[0][:command]).to match(%r{\$HOME/bin/daily.job >> \$HOME/tmp/out 2>&1})
225225
expect(parameters[0][:ensure]).to eq(:present)
226-
expect(parameters[0][:environment]).to eq(:absent)
226+
expect(parameters[0][:environment]).to eq([])
227227
expect(parameters[0][:user]).to eq(:absent)
228228

229229
expect(parameters[1][:name]).to match(%r{unmanaged:\$HOME/bin/monthly-\d+})
@@ -235,7 +235,7 @@
235235
expect(parameters[1][:special]).to eq(:absent)
236236
expect(parameters[1][:command]).to match(%r{\$HOME/bin/monthly})
237237
expect(parameters[1][:ensure]).to eq(:present)
238-
expect(parameters[1][:environment]).to eq(:absent)
238+
expect(parameters[1][:environment]).to eq([])
239239
expect(parameters[1][:user]).to eq(:absent)
240240
expect(parameters[1][:target]).to eq('foobar')
241241
end
@@ -259,7 +259,7 @@
259259
special: :absent,
260260
command: '/bin/true',
261261
ensure: :present,
262-
environment: :absent,
262+
environment: [],
263263
user: :absent,
264264
target: 'foobar',
265265
},

0 commit comments

Comments
 (0)