Skip to content

Commit c798ae1

Browse files
committed
test: add tests for not reloading service
1 parent 7ac0fe0 commit c798ae1

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

spec/defines/dropin_file_spec.rb

+24-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
require 'spec_helper'
44

5+
RSpec::Matchers.define_negated_matcher :that_doesnt_notify, :that_notifies
6+
RSpec::Matchers.define_negated_matcher :that_doesnt_subscribe_to, :that_subscribes_to
7+
58
describe 'systemd::dropin_file' do
69
context 'supported operating systems' do
710
on_supported_os.each do |os, facts|
@@ -69,8 +72,28 @@
6972

7073
it { is_expected.to compile.with_all_deps }
7174
it { is_expected.to contain_service('myservice').that_subscribes_to("File[#{filename}]") }
72-
it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_notifies('Service[myservice]') }
75+
it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_comes_before('Service[myservice]') }
76+
it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_doesnt_notify('Service[myservice]') }
77+
end
78+
end
79+
80+
context 'doesn\'t notify services' do
81+
let(:params) do
82+
super().merge(notify_service: false)
83+
end
84+
let(:filename) { "/etc/systemd/system/#{params[:unit]}.d/#{title}" }
85+
let(:pre_condition) do
86+
<<-PUPPET
87+
service { ['test', 'test.service']:
88+
}
89+
PUPPET
7390
end
91+
92+
it { is_expected.to compile.with_all_deps }
93+
it { is_expected.to contain_service('test').that_doesnt_subscribe_to("File[#{filename}]") }
94+
it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("File[#{filename}]") }
95+
it { is_expected.to contain_service('test').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") }
96+
it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") }
7497
end
7598

7699
context 'with selinux_ignore_defaults set to true' do

0 commit comments

Comments
 (0)