Skip to content

Commit

Permalink
Merge pull request #9443 from jordanbreen28/bug-honour_custom_insync_…
Browse files Browse the repository at this point in the history
…in_noop

(bug) - Honour custom insync in noop mode
  • Loading branch information
joshcooper authored Aug 6, 2024
2 parents 06a56b6 + 365c5a6 commit 5c078c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/puppet/transaction/resource_harness.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@ def audit_message(param, do_audit, historical_value, current_value)
end

def noop(event, param, current_value, audit_message)
event.message = param.format(_("current_value %s, should be %s (noop)"),
param.is_to_s(current_value),
param.should_to_s(param.should)) + audit_message.to_s
if param.sensitive
event.message = param.format(_("current_value %s, should be %s (noop)"),
param.is_to_s(current_value),
param.should_to_s(param.should)) + audit_message.to_s
else
event.message = "#{param.change_to_s(current_value, param.should)} (noop)#{audit_message}"
end
event.status = "noop"
end

Expand Down
13 changes: 13 additions & 0 deletions spec/unit/transaction/resource_harness_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def insync?(value)
def should_to_s(value)
(@resource.behaviors[:on_should_to_s] || proc { "'#{value}'" }).call
end

def change_to_s(value, should)
"some custom insync message"
end
end

newparam(:name) do
Expand Down Expand Up @@ -249,6 +253,7 @@ def self.name
expect(status.events[0].property).to eq('ensure')
expect(status.events[0].name.to_s).to eq('Testing_created')
expect(status.events[0].status).to eq('success')
expect(status.events[0].message).to eq 'some custom insync message'
end

it "ensure is in sync means that the rest *does* happen" do
Expand Down Expand Up @@ -283,6 +288,14 @@ def self.name
expect(testing_errors[0].message).not_to be_nil
expect(resource_errors[0].message).not_to eq("Puppet::Util::Log requires a message")
end

it "displays custom insync message in noop" do
resource = an_ensurable_resource_reacting_as(:present? => true)
resource[:noop] = true
status = @harness.evaluate(resource)
sync_event = status.events[0]
expect(sync_event.message).to eq 'some custom insync message (noop)'
end
end

describe "when a caught error occurs" do
Expand Down

0 comments on commit 5c078c8

Please sign in to comment.