Skip to content
Merged
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
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