Skip to content

Commit 67326dc

Browse files
authored
Merge pull request #9213 from mhashizume/PUP-11656/main/macos-systemd
Clean up SystemD tests
2 parents 09904df + 5a33635 commit 67326dc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

spec/unit/provider/service/systemd_spec.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Puppet::Util::Execution::ProcessOutput.new('', 0)
1919
end
2020

21-
osfamilies = [ 'archlinux', 'coreos', 'gentoo' ]
21+
osfamilies = %w[archlinux coreos gentoo]
2222

2323
osfamilies.each do |osfamily|
2424
it "should be the default provider on #{osfamily}" do
@@ -38,7 +38,7 @@
3838
end
3939
end
4040

41-
[ 4, 5, 6 ].each do |ver|
41+
[4, 5, 6].each do |ver|
4242
it "should not be the default provider on rhel#{ver}" do
4343
allow(Facter).to receive(:value).with('os.family').and_return(:redhat)
4444
allow(Facter).to receive(:value).with('os.name').and_return(:redhat)
@@ -47,7 +47,7 @@
4747
end
4848
end
4949

50-
[ 17, 18, 19, 20, 21, 22, 23 ].each do |ver|
50+
(17..23).to_a.each do |ver|
5151
it "should be the default provider on fedora#{ver}" do
5252
allow(Facter).to receive(:value).with('os.family').and_return(:redhat)
5353
allow(Facter).to receive(:value).with('os.name').and_return(:fedora)
@@ -56,7 +56,7 @@
5656
end
5757
end
5858

59-
[ 2, 2023 ].each do |ver|
59+
[2, 2023].each do |ver|
6060
it "should be the default provider on Amazon Linux #{ver}" do
6161
allow(Facter).to receive(:value).with('os.family').and_return(:redhat)
6262
allow(Facter).to receive(:value).with('os.name').and_return(:amazon)
@@ -144,7 +144,7 @@
144144
expect(provider_class).not_to be_default
145145
end
146146

147-
[ '15.04', '15.10', '16.04', '16.10', '17.04', '17.10', '18.04' ].each do |ver|
147+
%w[15.04 15.10 16.04 16.10 17.04 17.10 18.04].each do |ver|
148148
it "should be the default provider on ubuntu#{ver}" do
149149
allow(Facter).to receive(:value).with('os.family').and_return(:debian)
150150
allow(Facter).to receive(:value).with('os.name').and_return(:ubuntu)
@@ -153,7 +153,7 @@
153153
end
154154
end
155155

156-
[ '10', '11', '12', '13', '14', '15', '16', '17' ].each do |ver|
156+
('10'..'17').to_a.each do |ver|
157157
it "should not be the default provider on LinuxMint#{ver}" do
158158
allow(Facter).to receive(:value).with('os.family').and_return(:debian)
159159
allow(Facter).to receive(:value).with('os.name').and_return(:LinuxMint)
@@ -162,7 +162,7 @@
162162
end
163163
end
164164

165-
[ '18', '19' ].each do |ver|
165+
['18', '19'].each do |ver|
166166
it "should be the default provider on LinuxMint#{ver}" do
167167
allow(Facter).to receive(:value).with('os.family').and_return(:debian)
168168
allow(Facter).to receive(:value).with('os.name').and_return(:LinuxMint)
@@ -171,7 +171,7 @@
171171
end
172172
end
173173

174-
[:enabled?, :daemon_reload?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
174+
%i[enabled? daemon_reload? enable disable start stop status restart].each do |method|
175175
it "should have a #{method} method" do
176176
expect(provider).to respond_to(method)
177177
end
@@ -335,6 +335,7 @@
335335

336336
it "should consider nonexistent services to be disabled" do
337337
provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'doesnotexist'))
338+
allow(Facter).to receive(:value).with('os.family').and_return('debian')
338339
expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'doesnotexist'], {:failonfail => false})
339340
.and_return(Puppet::Util::Execution::ProcessOutput.new("", 1))
340341
expect(provider).to receive(:execute).with(["/usr/sbin/invoke-rc.d", "--quiet", "--query", "doesnotexist", "start"], {:failonfail => false})

0 commit comments

Comments
 (0)