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

don't stringify custom facts; require rspec-puppet-facts 3.x #131

Closed
wants to merge 3 commits into from

Conversation

bastelfreak
Copy link
Member

rspec-puppet-facts has an option to stringify all facts:

https://github.com/voxpupuli/rspec-puppet-facts/blob/fd600001c1cc9cb0bd2522188f4a8feb15f7cf40/lib/rspec-puppet-facts.rb#L176

But this is called after our facts are added:

https://github.com/voxpupuli/rspec-puppet-facts/blob/fd600001c1cc9cb0bd2522188f4a8feb15f7cf40/lib/rspec-puppet-facts.rb#L173

That means that voxpupuli-test doesn't need to care how RSpec.configuration.facterdb_string_keys is set. rspec-puppet-facts deal with it afterwards.

@bastelfreak bastelfreak added the bug Something isn't working label May 24, 2024
@bastelfreak bastelfreak self-assigned this May 24, 2024
rspec-puppet-facts has an option to stringify all facts:

https://github.com/voxpupuli/rspec-puppet-facts/blob/fd600001c1cc9cb0bd2522188f4a8feb15f7cf40/lib/rspec-puppet-facts.rb#L176

But this is called *after* our facts are added:

https://github.com/voxpupuli/rspec-puppet-facts/blob/fd600001c1cc9cb0bd2522188f4a8feb15f7cf40/lib/rspec-puppet-facts.rb#L173

That means that voxpupuli-test doesn't need to care how
RSpec.configuration.facterdb_string_keys is set. rspec-puppet-facts deal
with it afterwards.
@bastelfreak bastelfreak changed the title dont stringify custom facts dont stringify custom facts; require rspec-puppet-facts 3.x May 24, 2024
@bastelfreak bastelfreak added backwards-incompatible and removed bug Something isn't working labels May 24, 2024
@bastelfreak
Copy link
Member Author

tested at voxpupuli/puppet-example#51

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I think these are bugs in rspec-puppet-facts. With string keys, all keys should be strings. Not some as symbols, some as strings.

@bastelfreak
Copy link
Member Author

everything that rspec-puppet-facts returns in the end are strings. You can see that here: https://github.com/voxpupuli/puppet-example/actions/runs/9227133359/job/25388427471?pr=51

custom facts are always added as symbols and depending on facterdb_string_keys rspec-puppet-facts converts everything at the end to strings or stays with symbols.

@@ -71,8 +71,7 @@ def add_stdlib_facts
# Rough conversion of grepping in the puppet source:
# grep defaultfor lib/puppet/provider/service/*.rb
add_custom_fact :service_provider, ->(_os, facts) do
os = RSpec.configuration.facterdb_string_keys ? facts['os'] : facts[:os]
Copy link
Member

Choose a reason for hiding this comment

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

If we set facterdb_string_keys to true, this must be facts['os']. Otherwise the whole setting doesn't make sense. IMHO it's a bug.

bastelfreak added a commit to bastelfreak/rspec-puppet-facts that referenced this pull request May 24, 2024
bastelfreak added a commit to bastelfreak/rspec-puppet-facts that referenced this pull request May 24, 2024
@bastelfreak bastelfreak marked this pull request as draft May 24, 2024 21:31
@kenyon kenyon changed the title dont stringify custom facts; require rspec-puppet-facts 3.x don't stringify custom facts; require rspec-puppet-facts 3.x May 27, 2024
@bastelfreak bastelfreak closed this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants