Skip to content

Instantly share code, notes, and snippets.

@alexharv074
Last active March 13, 2019 23:18
Show Gist options
  • Save alexharv074/47b2238ec9183491dceaae1d31837820 to your computer and use it in GitHub Desktop.
Save alexharv074/47b2238ec9183491dceaae1d31837820 to your computer and use it in GitHub Desktop.
# common.yaml:
---
service::common::httpd::packages: [ "Package['package-x']", "Package['package-y']" ]
# init.pp:
class test {
package { 'package-x': ensure => installed }
package { 'package-y': ensure => installed }
$packages = lookup('service::common::httpd::packages')
notify { 'message':
require => $packages,
}
}
# test case
describe 'test' do
let(:hiera_config) { 'spec/fixtures/hiera/hiera.yaml' }
it 'should compile' do
is_expected.to compile
File.write(
'myclass.json',
PSON.pretty_generate(catalogue)
)
end
end
Results:
Puppet 6.3
Failures:
1) test should compile
Failure/Error: is_expected.to compile
error during compilation: Could not find resource 'Package['package-x']' in parameter 'require' (file: /Users/alexharvey/git/home/puppet-test/spec/fixtures/modules/test/manifests/init.pp, line: 7) on node alexs-macbook-pro.local
# ./spec/classes/test_spec.rb:6:in `block (2 levels) in <top (required)>'
Interestingly it fails in a different way for Puppet 4.10.12 and 5.5.10:
Failures:
1) test should compile
Failure/Error: is_expected.to compile
error during compilation: Could not retrieve dependency 'Package['package-x']' of Notify[message]
# ./spec/classes/test_spec.rb:6:in `block (2 levels) in <top (required)>'
For both latest Puppet 6 and 4, the fix is the same, to remove the single quotes from the YAML.
Testing for Puppet 3 was too much trouble to set up.
https://stackoverflow.com/a/55142359/3787051
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment