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

Fix spec tests #97

Merged
merged 1 commit into from Sep 3, 2018
Merged

Fix spec tests #97

merged 1 commit into from Sep 3, 2018

Conversation

coreone
Copy link
Contributor

@coreone coreone commented May 7, 2018

  • Fix variable reference in templates/cert.cnf.erb to fix spec tests.
  • The error message for Absolutepath is different between Puppet 4 and Puppet 5, so spec tests can't check for the exception type anymore, just the error string.

@coreone coreone changed the title Fix variable reference in templates/cert.cnf.erb to fix spec tests Fix spec tests May 7, 2018
@@ -35,7 +35,7 @@ commonName = <%= @commonname %>
emailAddress = <%= @email %>
<% end -%>

<% if $req_ext == true -%>
<% if @req_ext == true -%>
Copy link
Member

Choose a reason for hiding this comment

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

Oh my, that was quite broken then

is_expected.to contain_file('/etc/ssl/dhparam.pem')
}.to raise_error(Puppet::Error, /got 'foo'/)
is_expected.to contain_file('/etc/ssl/dhparam.pem')
}.to raise_error(Puppet::Error)
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather check the error content still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raphink The reason I changed this test to be less specific is due to a change in how this exception is raised in either a different Ruby version, or a newer version of Puppet. I haven't figured out which of these triggered it yet. Basically, changing this rule was the only way to get the spec tests to pass. If you have another suggestion that will work across all versions and keep the content check in place, I would be happy to use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I understand the error message changed between Puppet versions (unfortunately this happens quite often). Maybe the code could just check for the value 'foo' in the output, just to avoid catching other errors.

@coreone
Copy link
Contributor Author

coreone commented Aug 9, 2018

I just changed the spec tests as you suggested, and as you can see, Puppet 5 checks still fail. The error is

expected Puppet::Error with message matching /barz/, got #<Puppet::PreformattedError: Evaluation Error: Error while evaluating a Resource Statement, Openssl::.../]] value, got String (line: 2)

I'm not a Ruby/spec expert, so I'm not sure where to go from here to catch both a Puppet::Error exception as well as the text in that exception for both Puppet 4 and 5. If you have any other suggestions, I am happy to try them out in this branch.

@raphink
Copy link
Member

raphink commented Aug 21, 2018

Yes, this is linked to the fact that errors with data type checking are different than the ones with validate_*() functions. You can just go ahead and adjust the specs to match the new error.

* The error message for Absolutepath is different between Puppet 4 and Puppet 5, so spec tests can't check for the error message anymore, just the error.
@coreone
Copy link
Contributor Author

coreone commented Aug 25, 2018

@raphink This should be fixed now. I updated the regular expression to catch both wordings of the exception, so it should work on Puppet 4/5 now.

@raphink raphink merged commit e8b3330 into voxpupuli:master Sep 3, 2018
@raphink raphink added the bugfix label Mar 5, 2020
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.

None yet

2 participants