|
13 | 13 | end |
14 | 14 |
|
15 | 15 | let(:title) { 'test' } |
16 | | - let(:params) do |
17 | | - { |
18 | | - instances: [ |
19 | | - { |
20 | | - one: 'two', |
21 | | - }, |
22 | | - ], |
23 | | - } |
24 | | - end |
25 | 16 |
|
26 | | - it { is_expected.to compile } |
| 17 | + gem_spec = Gem.loaded_specs['puppet'] |
| 18 | + |
27 | 19 | if agent_major_version == 5 |
28 | 20 | it { is_expected.to contain_file(conf_dir.to_s).that_comes_before("File[#{conf_file}]") } |
29 | 21 | end |
30 | | - it { is_expected.to contain_file(conf_file.to_s).with_content(%r{init_config: }) } |
31 | | - gem_spec = Gem.loaded_specs['puppet'] |
32 | | - if gem_spec.version >= Gem::Version.new('4.0.0') |
33 | | - it { is_expected.to contain_file(conf_file.to_s).with_content(%r{---\ninit_config: \ninstances:\n- one: two\n}) } |
34 | | - else |
35 | | - it { is_expected.to contain_file(conf_file.to_s).with_content(%r{--- \n init_config: \n instances: \n - one: two}) } |
36 | | - end |
37 | 22 | it { is_expected.to contain_file(conf_file.to_s).that_notifies("Service[#{SERVICE_NAME}]") } |
38 | 23 |
|
| 24 | + context 'with instances' do |
| 25 | + let(:params) do |
| 26 | + { |
| 27 | + instances: [ |
| 28 | + { |
| 29 | + one: 'two', |
| 30 | + }, |
| 31 | + ], |
| 32 | + } |
| 33 | + end |
| 34 | + |
| 35 | + it { is_expected.to compile } |
| 36 | + if gem_spec.version >= Gem::Version.new('4.0.0') |
| 37 | + it { is_expected.to contain_file(conf_file.to_s).with_content(%r{---\ninit_config: \ninstances:\n- one: two\n}) } |
| 38 | + else |
| 39 | + it { is_expected.to contain_file(conf_file.to_s).with_content(%r{--- \n init_config: \n instances: \n - one: two}) } |
| 40 | + end |
| 41 | + it { is_expected.to contain_file(conf_file).with_ensure('file') } |
| 42 | + end |
| 43 | + |
39 | 44 | context 'with logs' do |
40 | 45 | let(:params) do |
41 | 46 | { |
|
48 | 53 | } |
49 | 54 | end |
50 | 55 |
|
| 56 | + it { is_expected.to compile } |
51 | 57 | if gem_spec.version >= Gem::Version.new('4.0.0') |
52 | 58 | it { is_expected.to contain_file(conf_file).with_content(%r{logs:\n- one\n- two}) } |
53 | 59 | else |
54 | 60 | it { is_expected.to contain_file(conf_file).with_content(%r{logs:\n - one\n - two}) } |
55 | 61 | end |
| 62 | + it { is_expected.to contain_file(conf_file).with_ensure('file') } |
| 63 | + end |
| 64 | + |
| 65 | + context 'with ensure absent' do |
| 66 | + let(:params) do |
| 67 | + { |
| 68 | + ensure: 'absent', |
| 69 | + } |
| 70 | + end |
| 71 | + |
| 72 | + it { is_expected.to compile } |
| 73 | + it { is_expected.to contain_file(conf_file).with_ensure('absent') } |
56 | 74 | end |
57 | 75 | end |
58 | 76 | end |
|
0 commit comments