File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 $dst = " ${datadog_agent::params::legacy_conf_dir} /${integration} .yaml"
2222 }
2323
24+ $file_ensure = $ensure ? { default => file , ' absent' => absent }
25+
2426 file { $dst:
25- ensure => $ensure ? { default => file , ' absent ' => absent } ,
27+ ensure => $file_ensure ,
2628 owner => $datadog_agent::dd_user ,
2729 group => $datadog_agent::dd_group ,
2830 mode => $datadog_agent::params::permissions_file ,
Original file line number Diff line number Diff line change 99
1010 if agent_major_version == 5
1111 let ( :conf_file ) { '/etc/dd-agent/conf.d/test.yaml' }
12+
1213 else
1314 let ( :conf_dir ) { "#{ CONF_DIR } /test.d" }
1415 let ( :conf_file ) { "#{ conf_dir } /conf.yaml" }
1516 end
1617
1718 gem_spec = Gem . loaded_specs [ 'puppet' ]
1819
19- if agent_major_version == 5
20+ if agent_major_version > 5
2021 it { is_expected . to contain_file ( conf_dir . to_s ) . that_comes_before ( "File[#{ conf_file } ]" ) }
2122 end
2223 it { is_expected . to contain_file ( conf_file . to_s ) . that_notifies ( "Service[#{ SERVICE_NAME } ]" ) }
3132 ] ,
3233 }
3334 end
35+
3436 it { is_expected . to compile }
3537 if gem_spec . version >= Gem ::Version . new ( '4.0.0' )
3638 it { is_expected . to contain_file ( conf_file . to_s ) . with_content ( %r{---\n init_config:\n instances:\n - one: two\n } ) }
3739 else
3840 it { is_expected . to contain_file ( conf_file . to_s ) . with_content ( %r{--- \n init_config:\n instances: \n - one: two} ) }
3941 end
42+ it { is_expected . to contain_file ( conf_file ) . with_ensure ( 'file' ) }
4043 end
4144
4245 context 'with logs' do
5053 logs : [ 'one' , 'two' ] ,
5154 }
5255 end
56+
5357 it { is_expected . to compile }
5458 if gem_spec . version >= Gem ::Version . new ( '4.0.0' )
5559 it { is_expected . to contain_file ( conf_file ) . with_content ( %r{logs:\n - one\n - two} ) }
5660 else
5761 it { is_expected . to contain_file ( conf_file ) . with_content ( %r{logs:\n - one\n - two} ) }
5862 end
63+ it { is_expected . to contain_file ( conf_file ) . with_ensure ( 'file' ) }
5964 end
6065
6166 context 'with ensure absent' do
6469 ensure : 'absent' ,
6570 }
6671 end
72+
6773 it { is_expected . to compile }
6874 it { is_expected . to contain_file ( conf_file ) . with_ensure ( 'absent' ) }
6975 end
70-
7176 end
7277 end
7378end
You can’t perform that action at this time.
0 commit comments