Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FacterDB: Use stringified keys #535

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 12 additions & 12 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
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 @@ -138,7 +138,7 @@ class { 'redis':
port 26379
tls-port 26380
dir /tmp/redis
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
daemonize #{facts['os']['family'] == 'RedHat' ? 'no' : 'yes'}
supervised auto
pidfile #{pidfile}
protected-mode no
Expand Down Expand Up @@ -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
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
16 changes: 8 additions & 8 deletions spec/classes/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

# rubocop:disable RSpec/MultipleMemoizedHelpers
describe 'redis' do
let(:package_name) { facts[:os]['family'] == 'Debian' ? 'redis-server' : 'redis' }
let(:package_name) { facts['os']['family'] == 'Debian' ? 'redis-server' : 'redis' }
let(:service_name) { package_name }
let(:config_file) do
case facts[:os]['family']
case facts['os']['family']
when 'Archlinux', 'Debian'
'/etc/redis/redis.conf'
when 'FreeBSD'
'/usr/local/etc/redis.conf'
when 'RedHat'
if facts[:os]['release']['major'].to_i > 8
if facts['os']['release']['major'].to_i > 8
'/etc/redis/redis.conf'
else
'/etc/redis.conf'
Expand Down Expand Up @@ -42,7 +42,7 @@
with_content(%r{logfile /var/log/redis/redis\.log}).
without_content(%r{undef})

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

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

describe 'with manage_dnf_module true', if: facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i == 8 do
describe 'with manage_dnf_module true', if: facts['os']['family'] == 'RedHat' && facts['os']['release']['major'].to_i == 8 do
let(:pre_condition) do
<<-PUPPET
class { 'redis':
Expand All @@ -61,7 +61,7 @@
PUPPET
end

it { is_expected.to compile.with_all_deps }

Check failure on line 64 in spec/classes/redis_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

redis on redhat-8-x86_64 without parameters with manage_dnf_module true is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } ArgumentError: Cannot alias Package[redis dnf module] to [nil, "redis", :dnfmodule] at (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/dnfmodule.pp, line: 18); resource ["Package", nil, "redis", :dnfmodule] already declared (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/install.pp, line: 5)

Check failure on line 64 in spec/classes/redis_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

redis on almalinux-8-x86_64 without parameters with manage_dnf_module true is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } ArgumentError: Cannot alias Package[redis dnf module] to [nil, "redis", :dnfmodule] at (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/dnfmodule.pp, line: 18); resource ["Package", nil, "redis", :dnfmodule] already declared (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/install.pp, line: 5)

Check failure on line 64 in spec/classes/redis_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

redis on rocky-8-x86_64 without parameters with manage_dnf_module true is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } ArgumentError: Cannot alias Package[redis dnf module] to [nil, "redis", :dnfmodule] at (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/dnfmodule.pp, line: 18); resource ["Package", nil, "redis", :dnfmodule] already declared (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/install.pp, line: 5)
it { is_expected.to contain_package('redis dnf module').with_ensure('6').that_comes_before('Package[redis]') }
it { is_expected.to contain_package('redis').with_name('redis') }
end
Expand Down Expand Up @@ -473,7 +473,7 @@
describe 'with ppa' do
let(:params) { super().merge(ppa_repo: 'ppa:rwky/redis') }

if facts[:os]['name'] == 'Ubuntu'
if facts['os']['name'] == 'Ubuntu'
it { is_expected.to contain_apt__ppa('ppa:rwky/redis') }
else
it { is_expected.not_to contain_apt__ppa('ppa:rwky/redis') }
Expand Down Expand Up @@ -1712,7 +1712,7 @@
)
}

if facts[:os]['family'] == 'Debian'
if facts['os']['family'] == 'Debian'
it {
is_expected.to contain_file('/etc/default/redis-server').
with(
Expand All @@ -1737,7 +1737,7 @@
}
end

if facts[:os]['family'] == 'Debian'
if facts['os']['family'] == 'Debian'
it {
is_expected.to contain_file('/etc/default/redis-server').
with(
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
Loading