Trey Ormsbee
2015-05-01 21:47:26 UTC
I have a puppet module that I am not sure hot to write a test for: Example
below:
class appsuite (
$param1,
$param2,
$param3,
$param4,
) {
include appsuite::params
include appsuite::repo
include appsuite::preconfig
}
#nothing in params, repo or preconfig really matter, other then preconfig
lays down a shared settings file: /etc/appsuite/settings
# /etc/appsuite/settings is required to be in place during the install of
any component of appsuite as it is sued to do its own setup.
So then I have a seperate class
class appsuite::component1 (
$component_param1,
$component_param2,
) {
...
package { 'component1': ensure => installed }
...
}
Now, class appsuite::component1 requires appsuite to be defined and all
those classes to be ran before it starts all it's magic. How do I test
that?
I got this
describe 'appsuite' do
context "test appsuite" do
let :params do {
param1 = 'blah1',
param2 = 'blah2',
param3 = 'blah3',
param4 = 'blah4',
}
end
it { is_expected.to contain_file('/etc/appsuite/settings').with({'mode'
=> '0644'}) }
end
end
Now the above works fine, but I do not understand how to then call
appsuite::component1 from that test with those parameters, I tried
nesting in the descibe, but it then says i need to pass params to
appsuite. Seems like this would be a pretty common thing to do so I hope I
am just missing something.
Any ideas?
Thanks
Trey
below:
class appsuite (
$param1,
$param2,
$param3,
$param4,
) {
include appsuite::params
include appsuite::repo
include appsuite::preconfig
}
#nothing in params, repo or preconfig really matter, other then preconfig
lays down a shared settings file: /etc/appsuite/settings
# /etc/appsuite/settings is required to be in place during the install of
any component of appsuite as it is sued to do its own setup.
So then I have a seperate class
class appsuite::component1 (
$component_param1,
$component_param2,
) {
...
package { 'component1': ensure => installed }
...
}
Now, class appsuite::component1 requires appsuite to be defined and all
those classes to be ran before it starts all it's magic. How do I test
that?
I got this
describe 'appsuite' do
context "test appsuite" do
let :params do {
param1 = 'blah1',
param2 = 'blah2',
param3 = 'blah3',
param4 = 'blah4',
}
end
it { is_expected.to contain_file('/etc/appsuite/settings').with({'mode'
=> '0644'}) }
end
end
Now the above works fine, but I do not understand how to then call
appsuite::component1 from that test with those parameters, I tried
nesting in the descibe, but it then says i need to pass params to
appsuite. Seems like this would be a pretty common thing to do so I hope I
am just missing something.
Any ideas?
Thanks
Trey
--
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 puppet-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/9f1a987b-a9d6-4f8a-befa-187c72d6d797%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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 puppet-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/9f1a987b-a9d6-4f8a-befa-187c72d6d797%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.