Skip to content

Commit

Permalink
test: add tests for not reloading service
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldwed committed Feb 8, 2024
1 parent 7ac0fe0 commit d8a93f0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion spec/defines/dropin_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

require 'spec_helper'

RSpec::Matchers.define_negated_matcher :that_doesnt_notify, :that_notifies
RSpec::Matchers.define_negated_matcher :that_doesnt_subscribe_to, :that_subscribes_to

describe 'systemd::dropin_file' do
context 'supported operating systems' do
on_supported_os.each do |os, facts|
Expand Down Expand Up @@ -69,10 +72,31 @@

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_service('myservice').that_subscribes_to("File[#{filename}]") }
it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_notifies('Service[myservice]') }
it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_comes_before('Service[myservice]') }
it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_doesnt_notify('Service[myservice]') }
end
end

context 'doesn\'t notify services' do
let(:params) do
super().merge(notify_service: false)
end
let(:filename) { "/etc/systemd/system/#{params[:unit]}.d/#{title}" }
let(:pre_condition) do
<<-PUPPET
service { ['test', 'test.service']:
}
PUPPET
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_service('test').that_doesnt_subscribe_to("File[#{filename}]") }
it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("File[#{filename}]") }
it { is_expected.to contain_service('test').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") }
it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") }
end


Check failure on line 99 in spec/defines/dropin_file_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Layout/EmptyLines: Extra blank line detected. (https://rubystyle.guide#two-or-more-empty-lines)
context 'with selinux_ignore_defaults set to true' do
let(:params) do
super().merge(selinux_ignore_defaults: true)
Expand Down

0 comments on commit d8a93f0

Please sign in to comment.