Skip to content

Commit e025c0d

Browse files
authored
Merge pull request #279 from puppetlabs/print_error
This PR adds the type checker error message to validation output
2 parents 5e6d445 + 70e1e22 commit e025c0d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/puppet/resource_api/type_definition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def check_schema_values(resource)
194194
if is_sensitive
195195
bad_vals[key] = '<< redacted value >> ' + error_message unless error_message.nil?
196196
else
197-
bad_vals[key] = value unless error_message.nil?
197+
bad_vals[key] = "#{value} (#{error_message})" unless error_message.nil?
198198
end
199199
end
200200
bad_vals

spec/puppet/resource_api/base_type_definition_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@
6969
context 'when resource contains invalid values' do
7070
let(:resource) { { name: 'test_string', prop: 'foo', ensure: 1 } }
7171

72-
it 'returns a hash of the keys that have invalid values' do
73-
expect(type.check_schema_values(resource)).to eq(prop: 'foo', ensure: 1)
72+
it 'returns a hash of the keys that have invalid values and error messages' do
73+
expect(type.check_schema_values(resource)).to eq(
74+
prop: 'foo (expects an Integer value, got String)',
75+
ensure: "1 (expects a match for Enum['absent', 'present'], got Integer)",
76+
)
7477
end
7578
end
7679
end

0 commit comments

Comments
 (0)