Revert "Add puppet/archive module"
[mirror/dsa-puppet.git] / 3rdparty / modules / systemd / spec / defines / dropin_file_spec.rb
1 require 'spec_helper'
2
3 describe 'systemd::dropin_file' do
4   context 'supported operating systems' do
5     on_supported_os.each do |os, facts|
6       context "on #{os}" do
7         let(:facts) { facts }
8
9         let(:title) { 'test.conf' }
10
11         let(:params) {{
12           :unit    => 'test.service',
13           :content => 'random stuff'
14         }}
15
16         it { is_expected.to compile.with_all_deps }
17
18         it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d").with(
19           :ensure  => 'directory',
20         ) }
21
22         it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").with(
23           :ensure  => 'file',
24           :content => /#{params[:content]}/,
25           :mode    => '0444'
26         ) }
27
28         it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{title}").that_notifies('Class[systemd::systemctl::daemon_reload]') }
29
30         context 'with a bad unit type' do
31           let(:title) { 'test.badtype' }
32
33           it {
34             expect{
35               is_expected.to compile.with_all_deps
36             }.to raise_error(/expects a match for Systemd::Dropin/)
37           }
38         end
39
40         context 'with another drop-in file with the same filename (and content)' do
41           let(:default_params) {{
42             :filename => 'longer-timeout.conf',
43             :content  => 'random stuff'
44           }}
45           # Create drop-in file longer-timeout.conf for unit httpd.service
46           let :pre_condition do
47             "systemd::dropin_file { 'httpd_longer-timeout':
48               filename => '#{default_params[:filename]}',
49               unit     => 'httpd.service',
50               content  => '#{default_params[:context]}',
51             }"
52           end
53           #
54           # Create drop-in file longer-timeout.conf for unit ftp.service
55           let (:title) {'ftp_longer-timeout'}
56           let :params do
57             default_params.merge({
58               :unit     => 'ftp.service'
59             })
60           end
61
62           it { is_expected.to create_file("/etc/systemd/system/#{params[:unit]}.d/#{params[:filename]}").with(
63             :ensure  => 'file',
64             :content => /#{params[:content]}/,
65             :mode    => '0444'
66           ) }
67         end
68       end
69     end
70   end
71 end