Hi
Look into rspec-puppet-utils <https://github.com/Accuity/rspec-puppet-utils>,
you can use the MockFunction class to completely mock hiera (there's an
example in the readme). This way your tests never even execute the real
hiera function, so you don't need to worry about yaml files, eyaml files,
hierarchies, eyaml installation, eyaml keys, etc
This is more like unit testing in a Java/C#/ruby project, where you're
isolating what you want to test away from it's dependencies. Mocking hiera
allows your tests to be very flexible with minimal setup, and you're also
not testing hiera/hiera-ayaml functionality in your tests for foo
Full disclosure: I wrote rspec-puppet-utils so naturally I think it's a
useful tool and a good fit in this case, but there are other ways of doing
it :)
Does that make sense? I hope it helps
On Friday, February 24, 2017 at 11:16:43 AM UTC-6, Stanislav Khromoy wrote:
>
>
> Need a little help with integrating unit testing ( rspec-puppet ) with
> eyaml encrypted data in hiera.
>
> I have something like this in heira:
>
> foo::foo_api_key: ENC[super long string of stuff]
>
> manifest:
>
> class { '::some_module_from_forge':
> apikey => hiera('foo::foo_api_key')
> }
>
> foo_spec.rb
>
> it { should contain_class('stackdriver').with_apikey(ENC[super long string
> of stuff])}
>
> I am not really sure how to quote this properly. Everything I've tried
> comes back with an error
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/cca91927-6b86-4bfc-a8ce-39b1cfcdc7cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.