Skip to content

Commit 43e1234

Browse files
committed
FacterDB: Use stringified keys
1 parent fd9cb3f commit 43e1234

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

.sync.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Gemfile:
66
- gem: 'mock_redis'
77
spec/spec_helper.rb:
88
mock_with: ":mocha"
9+
facterdb_string_keys: true

spec/classes/redis_sentinel_spec.rb

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
# rubocop:disable RSpec/MultipleMemoizedHelpers
66
describe 'redis::sentinel' do
7-
on_supported_os.each do |os, facts|
7+
on_supported_os.each do |os, os_facts|
88
context "on #{os}" do
9-
let(:facts) { facts }
9+
let(:facts) { os_facts }
1010
let(:config_file_orig) do
11-
case facts[:os]['family']
11+
case facts['os']['family']
1212
when 'Archlinux', 'Debian', 'Suse'
1313
'/etc/redis/redis-sentinel.conf.puppet'
1414
when 'FreeBSD'
1515
'/usr/local/etc/redis-sentinel.conf.puppet'
1616
when 'RedHat'
17-
if facts[:os]['release']['major'].to_i > 8
17+
if facts['os']['release']['major'].to_i > 8
1818
'/etc/redis/sentinel.conf.puppet'
1919
else
2020
'/etc/redis-sentinel.conf.puppet'
@@ -23,7 +23,7 @@
2323
end
2424

2525
let(:pidfile) do
26-
case facts[:os]['name']
26+
case facts['os']['name']
2727
when 'Ubuntu'
2828
'/var/run/sentinel/redis-sentinel.pid'
2929
when 'Debian'
@@ -38,7 +38,7 @@
3838
end
3939

4040
let(:sentinel_package_name) do
41-
if facts[:os]['family'] == 'Debian'
41+
if facts['os']['family'] == 'Debian'
4242
'redis-sentinel'
4343
else
4444
'redis'
@@ -49,8 +49,8 @@
4949
let(:expected_content) do
5050
<<~CONFIG
5151
port 26379
52-
dir #{facts[:os]['family'] == 'Debian' ? '/var/lib/redis' : '/tmp'}
53-
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
52+
dir #{facts['os']['family'] == 'Debian' ? '/var/lib/redis' : '/tmp'}
53+
daemonize #{facts['os']['family'] == 'RedHat' ? 'no' : 'yes'}
5454
supervised auto
5555
pidfile #{pidfile}
5656
protected-mode yes
@@ -61,7 +61,7 @@
6161
sentinel failover-timeout mymaster 180000
6262
6363
loglevel notice
64-
logfile #{facts[:os]['family'] == 'Debian' ? '/var/log/redis/redis-sentinel.log' : '/var/log/redis/sentinel.log'}
64+
logfile #{facts['os']['family'] == 'Debian' ? '/var/log/redis/redis-sentinel.log' : '/var/log/redis/sentinel.log'}
6565
CONFIG
6666
end
6767

@@ -138,7 +138,7 @@ class { 'redis':
138138
port 26379
139139
tls-port 26380
140140
dir /tmp/redis
141-
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
141+
daemonize #{facts['os']['family'] == 'RedHat' ? 'no' : 'yes'}
142142
supervised auto
143143
pidfile #{pidfile}
144144
protected-mode no
@@ -193,7 +193,7 @@ class { 'redis':
193193
bind 192.0.2.10 192.168.1.1
194194
port 26379
195195
dir /tmp/redis
196-
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
196+
daemonize #{facts['os']['family'] == 'RedHat' ? 'no' : 'yes'}
197197
supervised auto
198198
pidfile #{pidfile}
199199
protected-mode yes
@@ -232,7 +232,7 @@ class { 'redis':
232232
end
233233

234234
let(:package_ensure) do
235-
if facts[:os]['family'] == 'Debian'
235+
if facts['os']['family'] == 'Debian'
236236
'latest'
237237
else
238238
'installed'

spec/classes/redis_spec.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
# rubocop:disable RSpec/MultipleMemoizedHelpers
66
describe 'redis' do
7-
let(:package_name) { facts[:os]['family'] == 'Debian' ? 'redis-server' : 'redis' }
7+
let(:package_name) { facts['os']['family'] == 'Debian' ? 'redis-server' : 'redis' }
88
let(:service_name) { package_name }
99
let(:config_file) do
10-
case facts[:os]['family']
10+
case facts['os']['family']
1111
when 'Archlinux', 'Debian'
1212
'/etc/redis/redis.conf'
1313
when 'FreeBSD'
1414
'/usr/local/etc/redis.conf'
1515
when 'RedHat'
16-
if facts[:os]['release']['major'].to_i > 8
16+
if facts['os']['release']['major'].to_i > 8
1717
'/etc/redis/redis.conf'
1818
else
1919
'/etc/redis.conf'
@@ -42,7 +42,7 @@
4242
with_content(%r{logfile /var/log/redis/redis\.log}).
4343
without_content(%r{undef})
4444

45-
if facts[:os]['family'] == 'FreeBSD'
45+
if facts['os']['family'] == 'FreeBSD'
4646
is_expected.to contain_file(config_file_orig).
4747
with_content(%r{dir /var/db/redis}).
4848
with_content(%r{pidfile /var/run/redis/redis\.pid})
@@ -51,7 +51,7 @@
5151

5252
it { is_expected.to contain_service(service_name).with_ensure('running').with_enable('true') }
5353

54-
describe 'with manage_dnf_module true', if: facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i == 8 do
54+
describe 'with manage_dnf_module true', if: facts['os']['family'] == 'RedHat' && facts['os']['release']['major'].to_i == 8 do
5555
let(:pre_condition) do
5656
<<-PUPPET
5757
class { 'redis':
@@ -473,7 +473,7 @@ class { 'redis':
473473
describe 'with ppa' do
474474
let(:params) { super().merge(ppa_repo: 'ppa:rwky/redis') }
475475

476-
if facts[:os]['name'] == 'Ubuntu'
476+
if facts['os']['name'] == 'Ubuntu'
477477
it { is_expected.to contain_apt__ppa('ppa:rwky/redis') }
478478
else
479479
it { is_expected.not_to contain_apt__ppa('ppa:rwky/redis') }
@@ -1712,7 +1712,7 @@ class { 'redis':
17121712
)
17131713
}
17141714

1715-
if facts[:os]['family'] == 'Debian'
1715+
if facts['os']['family'] == 'Debian'
17161716
it {
17171717
is_expected.to contain_file('/etc/default/redis-server').
17181718
with(
@@ -1737,7 +1737,7 @@ class { 'redis':
17371737
}
17381738
end
17391739

1740-
if facts[:os]['family'] == 'Debian'
1740+
if facts['os']['family'] == 'Debian'
17411741
it {
17421742
is_expected.to contain_file('/etc/default/redis-server').
17431743
with(

spec/defines/instance_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ class { 'redis':
1111
PUPPET
1212
end
1313

14-
on_supported_os.each do |os, facts|
14+
on_supported_os.each do |os, os_facts|
1515
context "on #{os}" do
16-
let(:facts) { facts }
16+
let(:facts) { os_facts }
1717

1818
context 'with app2 title' do
1919
let(:title) { 'app2' }
2020
let(:config_file) do
21-
case facts[:os]['family']
21+
case facts['os']['family']
2222
when 'RedHat'
23-
if facts[:os]['release']['major'].to_i > 8
23+
if facts['os']['release']['major'].to_i > 8
2424
'/etc/redis/redis-server-app2.conf'
2525
else
2626
'/etc/redis-server-app2.conf'

spec/spec_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
require 'voxpupuli/test/spec_helper'
1111

1212
RSpec.configure do |c|
13-
c.facterdb_string_keys = false
13+
c.facterdb_string_keys = true
1414
c.mock_with :mocha
1515
end
1616

0 commit comments

Comments
 (0)