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

Ref option for repository fixtures is required #422

Closed
AlexandarY opened this issue Dec 19, 2023 · 0 comments · Fixed by #430
Closed

Ref option for repository fixtures is required #422

AlexandarY opened this issue Dec 19, 2023 · 0 comments · Fixed by #430
Labels

Comments

@AlexandarY
Copy link

Describe the Bug

Running unit tests with puppetlabs_spec_helper version 6.0.3 raises an error during spec_clean due to hash['ref'] being Nil. Looking at the fixtures.rb, the validate_fixture_hash method is attempting to validate that the ref option for repositories does not contain forward slash, but it doesn't consider at all the cases where ref is not set.

As per README.md :

used to specify the tag name (like version) or commit hash to be checked out (Optional). Branch names should use the branch option instead.

Exact error when running pdk test unit :

root@02d4a589e156:/workspaces/puppet-module# pdk test unit --tests spec/classes/custom_spec.rb --puppet-version 7.27.0
pdk (INFO): Using Ruby 2.7.8
pdk (INFO): Using Puppet 7.27.0
[✖] Preparing to run the unit tests.
[✖] Cleaning up after running unit tests.
pdk (ERROR): The spec_clean rake task failed with the following error(s):

rake aborted!
NoMethodError: undefined method `include?' for nil:NilClass
Did you mean?  include_repo?
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:154:in `validate_fixture_hash!'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:136:in `block in fixtures'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:120:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:120:in `fixtures'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:47:in `repositories'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:431:in `block in <top (required)>'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'

Expected Behavior

This started occurring after upgrade my local PDK Docker image to the latest version. Previously not having ref specified was working without issues.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a new puppet module via pdk new
  2. Add to .fixtures.yml the following content
---
fixtures:
  repositories:
    <repo-name>:
      repo: <url-to-a-puppet-module>
      scm: git
  1. Run pdk test unit.

Environment

  • Using latest PDK Docker image link

Additional Context

N/A

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 a pull request may close this issue.

1 participant