-
Notifications
You must be signed in to change notification settings - Fork 142
Description
Describe the Bug
Adding a top-level networking key in spec/default_facts.yml masks all values in the networking key from rspec-puppet-facts. For example, in tests networking.fqdn is not defined.
Expected Behavior
The networking facts provided by rspec-puppet-facts should work in tests.
Steps to Reproduce
Steps to reproduce the behavior:
pdk new module- Update
template-urlandtemplate-refto point to upstream.
"template-url": "https://github.com/puppetlabs/pdk-templates#3.0.0",
"template-ref": "tags/3.0.0-0-g5bfc1c0"pdk update- Create an empty class with
pdk new classand add the following to the generated spec test:
let(:pre_condition) do
<<~END
if $facts['networking']['fqdn'].empty {
fail("No fqdn fact: networking => ${facts['networking']}")
}
END
endpdk test unit
The resulting error will look like this:
Failure/Error: it { is_expected.to compile.with_all_deps }
error during compilation: Evaluation Error: Error while evaluating a Function Call, No fqdn fact: networking => {ip => 172.16.254.254, ip6 => FE80:0000:0000:0000:AAAA:AAAA:AAAA, mac => AA:AA:AA:AA:AA:AA}
Environment
- Version 3.0.0
- Platform Fedora 39 (using the Fedora 36 package)
Additional Context
In previous versions of the templates, only top-level keys were defined in spec/default_facts.yml, so the merge that was happening in spec/spec_helper.rb worked fine with default values. With nested facts added to spec/default_facts.yml, the merge needs to be replaced with a deep_merge.
Note that simply removing spec/default_facts.yml by adding
spec/default_facts.yml:
delete: trueto .sync.yml and running pdk update also works since the default provided facts are being provided by rspec-puppet-facts already.