|
106 | 106 | end |
107 | 107 |
|
108 | 108 | describe 'with run_every_thirty' do |
109 | | - [true, 'true', false, 'false'].each do |value| |
110 | | - [true, 'true', false, 'false'].each do |noop_value| |
| 109 | + [true, false].each do |value| |
| 110 | + [true, false].each do |noop_value| |
111 | 111 | context "set to #{value} (as #{value.class}) and run_in_noop set to #{noop_value} (as #{noop_value.class})" do |
112 | 112 | let(:params) do |
113 | 113 | { |
|
116 | 116 | } |
117 | 117 | end |
118 | 118 |
|
119 | | - if [true, 'true'].include?(value) |
| 119 | + if value == true |
120 | 120 | cron_ensure = 'present' |
121 | 121 | cron_minute = minute |
122 | 122 | else |
123 | 123 | cron_ensure = 'absent' |
124 | 124 | cron_minute = nil |
125 | 125 | end |
126 | 126 |
|
127 | | - cron_command = if [true, 'true'].include?(noop_value) |
| 127 | + cron_command = if noop_value == true |
128 | 128 | '/opt/puppetlabs/bin/puppet agent --onetime --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --noop' |
129 | 129 | else |
130 | 130 | '/opt/puppetlabs/bin/puppet agent --onetime --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay' |
|
173 | 173 | end |
174 | 174 |
|
175 | 175 | describe 'with run_at_boot' do |
176 | | - [true, 'true', false, 'false'].each do |value| |
| 176 | + [true, false].each do |value| |
177 | 177 | context "set to #{value} (as #{value.class})" do |
178 | 178 | let(:params) { { run_at_boot: value } } |
179 | 179 |
|
180 | | - foo = if [true, 'true'].include?(value) |
| 180 | + foo = if value == true |
181 | 181 | 'present' |
182 | 182 | else |
183 | 183 | 'absent' |
|
201 | 201 | end |
202 | 202 |
|
203 | 203 | describe 'with puppet.conf ini setting' do |
204 | | - ['server', 'ca_server', 'certname', 'graph'].each do |setting| |
| 204 | + ['server', 'ca_server', 'certname'].each do |setting| |
205 | 205 | context "#{setting} set to a valid entry" do |
206 | | - # 'true' is used because it is acceptable to all of the above |
207 | | - # parameters. Some of the settings are strings and some are boolean and |
208 | | - # stringified booleans. |
209 | | - let(:params) { { setting => 'true' } } |
| 206 | + let(:params) { { setting => 'testing' } } |
210 | 207 |
|
211 | 208 | it do |
212 | 209 | is_expected.to contain_ini_setting(setting).with( |
213 | 210 | { |
214 | | - ensure: 'present', |
| 211 | + ensure: 'present', |
215 | 212 | setting: setting, |
216 | | - value: 'true', |
217 | | - path: '/etc/puppetlabs/puppet/puppet.conf', |
| 213 | + value: 'testing', |
| 214 | + path: '/etc/puppetlabs/puppet/puppet.conf', |
218 | 215 | section: 'main', |
219 | 216 | require: 'File[puppet_config]', |
220 | 217 | }, |
|
224 | 221 | end |
225 | 222 | end |
226 | 223 |
|
| 224 | + context 'with graph set to a valid entry' do |
| 225 | + let(:params) { { graph: true } } |
| 226 | + |
| 227 | + it do |
| 228 | + is_expected.to contain_ini_setting('graph').with( |
| 229 | + { |
| 230 | + ensure: 'present', |
| 231 | + setting: 'graph', |
| 232 | + value: 'true', |
| 233 | + path: '/etc/puppetlabs/puppet/puppet.conf', |
| 234 | + section: 'main', |
| 235 | + require: 'File[puppet_config]', |
| 236 | + }, |
| 237 | + ) |
| 238 | + end |
| 239 | + end |
| 240 | + |
227 | 241 | describe 'with env specified' do |
228 | 242 | let(:params) { { env: 'myenv' } } |
229 | 243 |
|
|
315 | 329 | 'Stdlib::Absolutepath' => { |
316 | 330 | name: ['config_path', 'agent_sysconfig_path'], |
317 | 331 | valid: ['/absolute/path'], |
318 | | - invalid: ['not/an/absolute/path'], |
| 332 | + invalid: ['not/an/absolute/path', ['array'], { 'ha' => 'sh' }, 3, 2.42, false], |
319 | 333 | message: 'expects a Stdlib::Absolutepath', |
320 | 334 | }, |
321 | | - 'booleans' => { |
| 335 | + 'Boolean' => { |
322 | 336 | name: ['run_every_thirty', 'run_in_noop', 'run_at_boot', 'graph'], |
323 | | - valid: [true, 'true', false, 'false'], |
| 337 | + valid: [true, false], |
324 | 338 | invalid: ['string', ['array'], { 'ha' => 'sh' }, 3, 2.42], |
325 | | - message: 'Error while evaluating a Resource Statement', |
| 339 | + message: 'expects a Boolean', |
326 | 340 | }, |
327 | 341 | 'hash' => { |
328 | 342 | name: ['custom_settings'], |
329 | 343 | valid: [], # valid hashes are to complex to block test them here |
330 | | - invalid: ['string', ['array'], 3, 2.42, true, nil], |
| 344 | + invalid: ['string', ['array'], 3, 2.42, false, nil], |
331 | 345 | message: 'expects a Hash value', |
332 | 346 | }, |
333 | 347 | 'strings' => { |
334 | 348 | name: ['certname', 'cron_command', 'server', 'ca_server', 'env'], |
335 | 349 | valid: ['string'], |
336 | | - invalid: [true, ['array'], { 'ha' => 'sh' }, 3, 2.42], |
| 350 | + invalid: [true, ['array'], { 'ha' => 'sh' }, 3, 2.42, false], |
337 | 351 | message: 'Error while evaluating a Resource Statement', |
338 | 352 | }, |
339 | 353 | } |
|
0 commit comments