Skip to content

Commit a6f941c

Browse files
committed
Rely on voxpupuli-test to mock the service_provider fact
Custom facts in rspec-puppet-facts are strings, not symbols. This is inconsistent with other facts and confusing and will be fixed in the next major version of rspec-puppet-facts.
1 parent 9041c35 commit a6f941c

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

spec/classes/broker_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
describe 'kafka::broker', type: :class do
77
on_supported_os.each do |os, os_facts|
88
context "on #{os}" do
9-
os_facts = os_facts.merge({ service_provider: 'systemd' })
10-
119
let(:facts) do
1210
os_facts
1311
end
@@ -60,7 +58,7 @@
6058
end
6159

6260
context 'defaults' do
63-
if os_facts[:service_provider] == 'systemd'
61+
if os_facts['service_provider'] == 'systemd'
6462
it { is_expected.to contain_file('/etc/init.d/kafka').with_ensure('absent') }
6563
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=} }
6664
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=} }
@@ -74,7 +72,7 @@
7472
context 'limit_nofile set' do
7573
let(:params) { super().merge(limit_nofile: '65536') }
7674

77-
if os_facts[:service_provider] == 'systemd'
75+
if os_facts['service_provider'] == 'systemd'
7876
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=65536$} }
7977
else
8078
it { is_expected.to contain_file('/etc/init.d/kafka').with_content %r{ulimit -n 65536$} }
@@ -84,14 +82,14 @@
8482
context 'limit_core set' do
8583
let(:params) { super().merge(limit_core: 'infinity') }
8684

87-
if os_facts[:service_provider] == 'systemd'
85+
if os_facts['service_provider'] == 'systemd'
8886
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=infinity$} }
8987
else
9088
it { is_expected.to contain_file('/etc/init.d/kafka').with_content %r{ulimit -c infinity$} }
9189
end
9290
end
9391

94-
context 'service_requires set', if: os_facts[:service_provider] == 'systemd' do
92+
context 'service_requires set', if: os_facts['service_provider'] == 'systemd' do
9593
let(:params) { super().merge(service_requires: ['dummy.target']) }
9694

9795
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^After=dummy\.target$} }

spec/classes/consumer_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
describe 'kafka::consumer', type: :class do
77
on_supported_os.each do |os, os_facts|
88
context "on #{os}" do
9-
os_facts = os_facts.merge({ service_provider: 'systemd' })
10-
119
let(:facts) do
1210
os_facts
1311
end
@@ -53,7 +51,7 @@
5351

5452
describe 'kafka::consumer::service' do
5553
context 'defaults' do
56-
if os_facts[:service_provider] == 'systemd'
54+
if os_facts['service_provider'] == 'systemd'
5755
it { is_expected.to contain_file('/etc/systemd/system/kafka-consumer.service') }
5856
else
5957
it { is_expected.to contain_file('/etc/init.d/kafka-consumer') }

spec/classes/mirror_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
describe 'kafka::mirror', type: :class do
77
on_supported_os.each do |os, os_facts|
88
context "on #{os}" do
9-
os_facts = os_facts.merge({ service_provider: 'systemd' })
10-
119
let(:facts) do
1210
os_facts
1311
end
@@ -50,7 +48,7 @@
5048

5149
describe 'kafka::mirror::service' do
5250
context 'defaults' do
53-
if os_facts[:service_provider] == 'systemd'
51+
if os_facts['service_provider'] == 'systemd'
5452
it { is_expected.to contain_file('/etc/init.d/kafka-mirror').with_ensure('absent') }
5553
it { is_expected.to contain_file('/etc/systemd/system/kafka-mirror.service').with_content %r{/opt/kafka/config/(?=.*consumer)|(?=.*producer).propertie} }
5654
else

spec/classes/producer_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
describe 'kafka::producer', type: :class do
77
on_supported_os.each do |os, os_facts|
88
context "on #{os}" do
9-
os_facts = os_facts.merge({ service_provider: 'systemd' })
10-
119
let(:facts) do
1210
os_facts
1311
end
@@ -22,7 +20,7 @@
2220
}
2321
end
2422

25-
if os_facts[:service_provider] == 'systemd'
23+
if os_facts['service_provider'] == 'systemd'
2624
it { is_expected.to compile.and_raise_error(%r{Console Producer is not supported on systemd, because the stdin of the process cannot be redirected}) }
2725
else
2826
it { is_expected.to contain_class('kafka::producer::install').that_comes_before('Class[kafka::producer::config]') }

0 commit comments

Comments
 (0)