You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Hi,
I am having some trouble testing some classes using rspec.
I have three classes. init, service and config.
service contains just the service settings with a class setting for service name eg.
class tc::service ( $service_name => tc::service_name ) {
service {'tc': service_name => $service_name } }
init has a param for setting the service name
class tc ( $service_name => tc::params::service_name ) inherits tc::params {
class {'tc::service': service_name => $service_name } include tc::config }
The config class has something that notifies the service
class tc::config { file {'/foo/bar': notify => Service['tc'], } }
I am trying to test the service and config modules using rspec and get all sorts of errors about variable blank or classes not being loaded.
Is there some way to better set this up from a puppet point of view? Should I just test the init class? ( Seems to go against the unit tests a bit ) Is there a way in rspec to shim a class so that things like Service['tc'] appear to be available to the config class?
Thanks
john
Gareth Rushgrove
unread,
Apr 1, 2015, 11:22:51 AM4/1/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
> Should I just test the init class? ( Seems to go against the unit tests a
> bit )
I would say test the public interface not the implementation. If you
intend your individual classes to be public, test them directly. If
you don't then test them via the public interface (often init.pp).
Their are a bunch of bits in
https://speakerdeck.com/garethr/test-driven-development-for-puppet which might be useful.
The above linked Docker module also has a somewhat large (300+ tests)
rspec-puppet test suite which might be worth looking at, at least to
see how I approached the problem.
Gareth
> Is there a way in rspec to shim a class so that things like Service['tc']
> appear to be available to the config class?
>
> Thanks
>
> john
>