forked from puppetlabs/puppetlabs-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_config_spec.rb
94 lines (79 loc) · 2.53 KB
/
custom_config_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require 'spec_helper_acceptance'
require_relative './version.rb'
describe 'apache::custom_config define' do
context 'invalid config' do
it 'should not add the config' do
pp = <<-EOS
class { 'apache': }
apache::custom_config { 'acceptance_test':
content => 'INVALID',
}
EOS
apply_manifest(pp, :expect_failures => true)
end
describe file("#{$confd_dir}/25-acceptance_test.conf") do
it { is_expected.not_to be_file }
end
end
context 'valid config' do
it 'should add the config' do
pp = <<-EOS
class { 'apache': }
apache::custom_config { 'acceptance_test':
content => '# just a comment',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe file("#{$confd_dir}/25-acceptance_test.conf") do
it { is_expected.to contain '# just a comment' }
end
end
context 'with a custom filename' do
it 'should store content in the described file' do
pp = <<-EOS
class { 'apache': }
apache::custom_config { 'filename_test':
filename => 'custom_filename',
content => '# just another comment',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe file("#{$confd_dir}/custom_filename") do
it { is_expected.to contain '# just another comment' }
end
end
describe 'custom_config without priority prefix' do
it 'applies cleanly' do
pp = <<-EOS
class { 'apache': }
apache::custom_config { 'prefix_test':
priority => false,
content => '# just a comment',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe file("#{$confd_dir}/prefix_test.conf") do
it { is_expected.to be_file }
end
end
describe 'custom_config only applied after configs are written' do
it 'applies in the right order' do
pp = <<-EOS
class { 'apache': }
apache::custom_config { 'ordering_test':
content => '# just a comment',
}
# Try to wedge the apache::custom_config call between when httpd.conf is written and
# ports.conf is written. This should trigger a dependency cycle
File["#{$conf_file}"] -> Apache::Custom_config['ordering_test'] -> Concat["#{$ports_file}"]
EOS
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Found 1 dependency cycle/i)
end
describe file("#{$confd_dir}/25-ordering_test.conf") do
it { is_expected.not_to be_file }
end
end
end