Shortcut for creating unit files / tmpfiles
[puppet_systemd.git] / spec / defines / tmpfile_spec.rb
1 require 'spec_helper'
2
3 describe 'systemd::tmpfile' do
4
5   let(:facts) { {
6       :path => '/usr/bin',
7   } }
8
9   context 'default params' do
10
11     let(:title) { 'fancy.conf' }
12
13     it 'creates the tmpfile' do
14       should contain_file('/etc/tmpfiles.d/fancy.conf').with({
15                                                                  'ensure' => 'file',
16                                                                  'owner' => 'root',
17                                                                  'group' => 'root',
18                                                                  'mode' => '0444',
19                                                              })
20     end
21
22     it 'triggers systemd daemon-reload' do
23       should contain_class('systemd')
24       should contain_file('/etc/tmpfiles.d/fancy.conf').with_notify("Exec[systemd-tmpfiles-create]")
25     end
26   end
27
28   context 'with params' do
29     let(:title) { 'fancy.conf' }
30
31     let(:params) { {
32         :ensure => 'absent',
33         :path => '/etc/tmpfiles.d/foo',
34         :content => 'some-content',
35         :source => 'some-source',
36     } }
37
38     it 'creates the unit file' do
39       should contain_file('/etc/tmpfiles.d/foo/fancy.conf').with({
40                                                                      'ensure' => 'absent',
41                                                                      'content' => 'some-content',
42                                                                      'source' => 'some-source',
43                                                                  })
44     end
45
46   end
47
48 end