From 6357f10354bff9619f69930332a75c4b24844dc6 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 29 Sep 2024 00:39:59 +0200 Subject: [PATCH] FacterDB: Use stringified keys --- .sync.yml | 1 + spec/classes/redis_sentinel_spec.rb | 22 +++++++++++----------- spec/defines/instance_spec.rb | 8 ++++---- spec/spec_helper.rb | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.sync.yml b/.sync.yml index 4b30250d..e75830e2 100644 --- a/.sync.yml +++ b/.sync.yml @@ -6,3 +6,4 @@ Gemfile: - gem: 'mock_redis' spec/spec_helper.rb: mock_with: ":mocha" + facterdb_string_keys: true diff --git a/spec/classes/redis_sentinel_spec.rb b/spec/classes/redis_sentinel_spec.rb index 945d8561..54ecedad 100644 --- a/spec/classes/redis_sentinel_spec.rb +++ b/spec/classes/redis_sentinel_spec.rb @@ -4,17 +4,17 @@ # 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' '/usr/local/etc/redis-sentinel.conf.puppet' when 'RedHat' - if facts[:os]['release']['major'].to_i > 8 + if facts['os']['release']['major'].to_i > 8 '/etc/redis/sentinel.conf.puppet' else '/etc/redis-sentinel.conf.puppet' @@ -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' @@ -38,7 +38,7 @@ end let(:sentinel_package_name) do - if facts[:os]['family'] == 'Debian' + if facts['os']['family'] == 'Debian' 'redis-sentinel' else 'redis' @@ -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 @@ -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 @@ -193,7 +193,7 @@ class { 'redis': bind 192.0.2.10 192.168.1.1 port 26379 dir /tmp/redis - daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'} + daemonize #{facts['os']['family'] == 'RedHat' ? 'no' : 'yes'} supervised auto pidfile #{pidfile} protected-mode yes @@ -232,7 +232,7 @@ class { 'redis': end let(:package_ensure) do - if facts[:os]['family'] == 'Debian' + if facts['os']['family'] == 'Debian' 'latest' else 'installed' diff --git a/spec/defines/instance_spec.rb b/spec/defines/instance_spec.rb index c2a8db6d..690a8ab1 100644 --- a/spec/defines/instance_spec.rb +++ b/spec/defines/instance_spec.rb @@ -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' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3226b22d..b9b36691 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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