From 58172f91193d8693d3d3b695d24068cfbfc7c468 Mon Sep 17 00:00:00 2001 From: Fabien COMBERNOUS Date: Thu, 12 Sep 2024 17:11:42 +0200 Subject: [PATCH] fix idempotency for empty environment --- lib/puppet/provider/cron/crontab.rb | 2 +- .../tests/resource/cron/should_be_idempotent_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb index 33cd2b4..8d50df3 100644 --- a/lib/puppet/provider/cron/crontab.rb +++ b/lib/puppet/provider/cron/crontab.rb @@ -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. diff --git a/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb b/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb index 35a91b7..3214864 100644 --- a/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb @@ -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