Add target param for the unit file (#10)
[puppet_systemd.git] / spec / defines / unit_file_spec.rb
1 require 'spec_helper'
2
3 describe 'systemd::unit_file' do
4
5   let(:facts) { {
6       :path => '/usr/bin',
7   } }
8
9   context 'default params' do
10
11     let(:title) { 'fancy.service' }
12
13     it 'creates the unit file' do
14       should contain_file('/etc/systemd/system/fancy.service').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/systemd/system/fancy.service').with_notify("Exec[systemctl-daemon-reload]")
25     end
26   end
27
28   context 'with params' do
29     let(:title) { 'fancy.service' }
30
31     let(:params) { {
32         :ensure => 'absent',
33         :path => '/usr/lib/systemd/system',
34         :content => 'some-content',
35         :source => 'some-source',
36         :target => 'some-target',
37     } }
38
39     it 'creates the unit file' do
40       should contain_file('/usr/lib/systemd/system/fancy.service').with({
41                                                                             'ensure' => 'absent',
42                                                                             'content' => 'some-content',
43                                                                             'source' => 'some-source',
44                                                                             'target' => 'some-target',
45                                                                         })
46     end
47
48   end
49
50 end