Skip to content

Commit

Permalink
FacterDB: Use stringified keys
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Sep 28, 2024
1 parent fd9cb3f commit 39aca76
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Gemfile:
- gem: 'mock_redis'
spec/spec_helper.rb:
mock_with: ":mocha"
facterdb_string_keys: true
18 changes: 9 additions & 9 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

# rubocop:disable RSpec/MultipleMemoizedHelpers
describe 'redis::sentinel' do
on_supported_os.each do |os, facts|
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { facts }
let(:facts) { os_facts }
let(:config_file_orig) do
case facts[:os]['family']
case facts['os']['family']
when 'Archlinux', 'Debian', 'Suse'
'/etc/redis/redis-sentinel.conf.puppet'
when 'FreeBSD'
Expand All @@ -23,7 +23,7 @@
end

let(:pidfile) do
case facts[:os]['name']
case facts['os']['name']
when 'Ubuntu'
'/var/run/sentinel/redis-sentinel.pid'
when 'Debian'
Expand All @@ -38,7 +38,7 @@
end

let(:sentinel_package_name) do
if facts[:os]['family'] == 'Debian'
if facts['os']['family'] == 'Debian'
'redis-sentinel'
else
'redis'
Expand All @@ -49,8 +49,8 @@
let(:expected_content) do
<<~CONFIG
port 26379
dir #{facts[:os]['family'] == 'Debian' ? '/var/lib/redis' : '/tmp'}
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
dir #{facts['os']['family'] == 'Debian' ? '/var/lib/redis' : '/tmp'}
daemonize #{facts['os']['family'] == 'RedHat' ? 'no' : 'yes'}
supervised auto
pidfile #{pidfile}
protected-mode yes
Expand All @@ -61,7 +61,7 @@
sentinel failover-timeout mymaster 180000
loglevel notice
logfile #{facts[:os]['family'] == 'Debian' ? '/var/log/redis/redis-sentinel.log' : '/var/log/redis/sentinel.log'}
logfile #{facts['os']['family'] == 'Debian' ? '/var/log/redis/redis-sentinel.log' : '/var/log/redis/sentinel.log'}
CONFIG
end

Expand Down Expand Up @@ -232,7 +232,7 @@ class { 'redis':
end

let(:package_ensure) do
if facts[:os]['family'] == 'Debian'
if facts['os']['family'] == 'Debian'
'latest'
else
'installed'
Expand Down
8 changes: 4 additions & 4 deletions spec/defines/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ class { 'redis':
PUPPET
end

on_supported_os.each do |os, facts|
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { facts }
let(:facts) { os_facts }

context 'with app2 title' do
let(:title) { 'app2' }
let(:config_file) do
case facts[:os]['family']
case facts['os']['family']
when 'RedHat'
if facts[:os]['release']['major'].to_i > 8
if facts['os']['release']['major'].to_i > 8
'/etc/redis/redis-server-app2.conf'
else
'/etc/redis-server-app2.conf'
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require 'voxpupuli/test/spec_helper'

RSpec.configure do |c|
c.facterdb_string_keys = false
c.facterdb_string_keys = true
c.mock_with :mocha
end

Expand Down

0 comments on commit 39aca76

Please sign in to comment.