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 c798ae1
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 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,8 +72,28 @@

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]') }

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on virtuozzolinux-7-x86_64 notifies services with overridden name Failure/Error: it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_doesnt_notify('Service[myservice]') } NoMethodError: undefined method `that_doesnt_notify' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d6462640 @exp_resource_type="systemd__daemon_reload", @Args=["test.service"], @block=nil, @referenced_type="Systemd::Daemon_reload", @title="test.service", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on gentoo-2-x86_64 notifies services with overridden name Failure/Error: it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_doesnt_notify('Service[myservice]') } NoMethodError: undefined method `that_doesnt_notify' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d8f6f158 @exp_resource_type="systemd__daemon_reload", @Args=["test.service"], @block=nil, @referenced_type="Systemd::Daemon_reload", @title="test.service", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on sles-15-x86_64 notifies services with overridden name Failure/Error: it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_doesnt_notify('Service[myservice]') } NoMethodError: undefined method `that_doesnt_notify' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00005636a204fc70> Did you mean? that_notifies

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on almalinux-8-x86_64 notifies services with overridden name Failure/Error: it { is_expected.to contain_systemd__daemon_reload(params[:unit]).that_doesnt_notify('Service[myservice]') } NoMethodError: undefined method `that_doesnt_notify' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00005636a01ea500> Did you mean? that_notifies
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}]") }

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on virtuozzolinux-7-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d9c4b868 @exp_resource_type="service", @Args=["test"], @block=nil, @referenced_type="Service", @title="test", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on gentoo-2-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d5a85140 @exp_resource_type="service", @Args=["test"], @block=nil, @referenced_type="Service", @title="test", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on sles-15-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369cf1e158> Did you mean? that_subscribes_to

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on almalinux-8-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369ec70d78> Did you mean? that_subscribes_to
it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("File[#{filename}]") }

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on virtuozzolinux-7-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d5a8ee20 @exp_resource_type="service", @Args=["test.service"], @block=nil, @referenced_type="Service", @title="test.service", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on gentoo-2-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d5aa5648 @exp_resource_type="service", @Args=["test.service"], @block=nil, @referenced_type="Service", @title="test.service", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on sles-15-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369cebf9f0> Did you mean? that_subscribes_to

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on almalinux-8-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("File[#{filename}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369ebbd070> Did you mean? that_subscribes_to
it { is_expected.to contain_service('test').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") }

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on virtuozzolinux-7-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d5a80320 @exp_resource_type="service", @Args=["test"], @block=nil, @referenced_type="Service", @title="test", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on gentoo-2-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d5ab3400 @exp_resource_type="service", @Args=["test"], @block=nil, @referenced_type="Service", @title="test", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on sles-15-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369ce65310> Did you mean? that_subscribes_to

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on almalinux-8-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369eb41358> Did you mean? that_subscribes_to
it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") }

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on virtuozzolinux-7-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d5b40d28 @exp_resource_type="service", @Args=["test.service"], @block=nil, @referenced_type="Service", @title="test.service", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

systemd::dropin_file supported operating systems on gentoo-2-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x00007f43d5ad1b80 @exp_resource_type="service", @Args=["test.service"], @block=nil, @referenced_type="Service", @title="test.service", @errors=[], @expected_params=[], @expected_undef_params=[], @notifies=[], @subscribes=[], @requires=[], @befores=[]>

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on sles-15-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369ce06540> Did you mean? that_subscribes_to

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

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

systemd::dropin_file supported operating systems on almalinux-8-x86_64 doesn't notify services Failure/Error: it { is_expected.to contain_service('test.service').that_doesnt_subscribe_to("Systemd::Daemon_reload[#{params[:unit]}]") } NoMethodError: undefined method `that_doesnt_subscribe_to' for #<RSpec::Puppet::ManifestMatchers::CreateGeneric:0x000056369eae7e70> Did you mean? that_subscribes_to
end

context 'with selinux_ignore_defaults set to true' do
Expand Down

0 comments on commit c798ae1

Please sign in to comment.