Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-882,PDK-883) validate only when needed #48

Merged
merged 4 commits into from
Mar 26, 2018

Conversation

DavidS
Copy link
Contributor

@DavidS DavidS commented Mar 26, 2018

No description provided.

When `puppet resource` tries to find a specific resource, it only passes
a hash with the title through. Puppet then calls validate, which
fails, because the `ensure` property is mandatory.

This change ignores a missing `:ensure` value if a call from `puppet resource`
is detected.

Added a bunch of acceptance-level tests to make sure that the `apply`
case still works.
When deleting resources, some validation has to be skipped. It does
not make sense to check properties, but parameters still need to be
checked.
expect(status.exitstatus).to eq 0
end

it 'validates property' do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new test for 'A mandatory property, that MUST NOT be validated on deleting.

output, status = Open3.capture2e("puppet apply #{common_args} -e \"test_validation{ foo: ensure => absent, prop => not_a_number }\"")
expect(output.strip).to match %r{Test_validation\[foo\]/ensure: undefined 'ensure' from 'present'}
expect(status.exitstatus).to eq 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather add a bunch of unit tests. The acceptance tests were primarily for the @called_from_resource, which I didn't need for PDK-883 in the end.

@da-ar da-ar merged commit 18821c7 into puppetlabs:master Mar 26, 2018
@DavidS DavidS deleted the pdk-882-fix-validation branch March 26, 2018 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants