summaryrefslogtreecommitdiff
path: root/spec/defines/tmpfile_spec.rb
blob: 4eb22acd58ab87cd07cd88e874868d1fe7f67c8d (plain)
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
require 'spec_helper'

describe 'systemd::tmpfile' do

  let(:facts) { {
      :path => '/usr/bin',
  } }

  context 'default params' do

    let(:title) { 'fancy.conf' }

    it 'creates the tmpfile' do
      should contain_file('/etc/tmpfiles.d/fancy.conf').with({
                                                                 'ensure' => 'file',
                                                                 'owner' => 'root',
                                                                 'group' => 'root',
                                                                 'mode' => '0444',
                                                             })
    end

    it 'triggers systemd daemon-reload' do
      should contain_class('systemd')
      should contain_file('/etc/tmpfiles.d/fancy.conf').with_notify("Exec[systemd-tmpfiles-create]")
    end
  end

  context 'with params' do
    let(:title) { 'fancy.conf' }

    let(:params) { {
        :ensure => 'absent',
        :path => '/etc/tmpfiles.d/foo',
        :content => 'some-content',
        :source => 'some-source',
    } }

    it 'creates the unit file' do
      should contain_file('/etc/tmpfiles.d/foo/fancy.conf').with({
                                                                     'ensure' => 'absent',
                                                                     'content' => 'some-content',
                                                                     'source' => 'some-source',
                                                                 })
    end

  end

end