Skip to content

Commit a6dc71c

Browse files
author
Kevin Paulisse
committed
Add unit tests for puppet service resource parameter
1 parent 72e4549 commit a6dc71c

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

spec/unit/classes/master/config_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,47 @@
9696

9797
end
9898

99+
context 'when restart_puppet is true' do
100+
let(:pre_condition) { 'class { "puppetdb": }' }
101+
102+
context 'with create_puppet_service_resource as default' do
103+
let(:params) do
104+
{
105+
:puppet_service_name => 'puppetserver',
106+
:restart_puppet => true,
107+
}
108+
end
109+
110+
it { should contain_service('puppetserver').with(:ensure => 'running') }
111+
end
112+
113+
context 'with create_puppet_service_resource = true' do
114+
let(:params) do
115+
{
116+
:create_puppet_service_resource => true,
117+
:puppet_service_name => 'puppetserver',
118+
:restart_puppet => true,
119+
}
120+
end
121+
122+
it { should contain_service('puppetserver').with(:ensure => 'running') }
123+
end
124+
125+
context 'with create_puppet_service_resource = false' do
126+
# Also setting the various parameters that notify the service to be false. Otherwise this error surfaces:
127+
# `Could not find resource 'Service[puppetserver]' for relationship from 'Class[Puppetdb::Master::Puppetdb_conf]'`
128+
let(:params) do
129+
{
130+
:create_puppet_service_resource => false,
131+
:manage_config => false,
132+
:manage_report_processor => false,
133+
:manage_routes => false,
134+
:puppet_service_name => 'puppetserver',
135+
:restart_puppet => true,
136+
}
137+
end
138+
139+
it { should_not contain_service('puppetserver') }
140+
end
141+
end
99142
end

0 commit comments

Comments
 (0)