From 303c9115cc2f5250f82ea5d9072e424654bf7bcf Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 26 Jun 2024 22:30:36 +0200 Subject: [PATCH] facterdb_string_keys: switch to strings --- .sync.yml | 1 + spec/classes/collectd_init_spec.rb | 2 +- spec/classes/collectd_plugin_apache_spec.rb | 2 +- spec/classes/collectd_plugin_disk_spec.rb | 2 +- spec/classes/collectd_plugin_java_spec.rb | 2 +- spec/classes/collectd_plugin_mcelog_spec.rb | 2 +- spec/classes/collectd_plugin_netlink_spec.rb | 4 ++-- spec/classes/collectd_plugin_ovs_events_spec.rb | 2 +- spec/classes/collectd_plugin_ovs_stats_spec.rb | 2 +- spec/classes/collectd_plugin_processes_spec.rb | 2 +- spec/classes/collectd_plugin_rabbitmq_spec.rb | 14 +++++++------- spec/classes/collectd_plugin_rrdtool_spec.rb | 2 +- spec/classes/collectd_plugin_smart_spec.rb | 2 +- spec/classes/collectd_plugin_virt_spec.rb | 4 ++-- spec/classes/collectd_plugin_write_http_spec.rb | 2 +- spec/spec_helper.rb | 4 ++++ spec/spec_helper_methods.rb | 2 +- 17 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.sync.yml b/.sync.yml index cb28c684..6d2a69c3 100644 --- a/.sync.yml +++ b/.sync.yml @@ -4,3 +4,4 @@ timeout_minutes: 75 spec/spec_helper.rb: spec_overrides: "require 'spec_helper_methods'" + facterdb_string_keys: true diff --git a/spec/classes/collectd_init_spec.rb b/spec/classes/collectd_init_spec.rb index f71a318a..d3483d10 100644 --- a/spec/classes/collectd_init_spec.rb +++ b/spec/classes/collectd_init_spec.rb @@ -48,7 +48,7 @@ context 'when utils true' do let(:params) { { utils: true } } - case "#{facts[:os]['family']}-#{facts[:os]['release']['major']}" + case "#{facts['os']['family']}-#{facts['os']['release']['major']}" when %r{^Debian-.+}, 'RedHat-8', 'RedHat-9' it { is_expected.to contain_package('collectd-utils') } else diff --git a/spec/classes/collectd_plugin_apache_spec.rb b/spec/classes/collectd_plugin_apache_spec.rb index 86435561..ffb58790 100644 --- a/spec/classes/collectd_plugin_apache_spec.rb +++ b/spec/classes/collectd_plugin_apache_spec.rb @@ -103,7 +103,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context ':manage_package => true on osfamily => RedHat' do let :params do diff --git a/spec/classes/collectd_plugin_disk_spec.rb b/spec/classes/collectd_plugin_disk_spec.rb index 73b3870c..6d360a72 100644 --- a/spec/classes/collectd_plugin_disk_spec.rb +++ b/spec/classes/collectd_plugin_disk_spec.rb @@ -110,7 +110,7 @@ end end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8] context ':manage_package => undef with collectd 5.5 and up' do let :facts do diff --git a/spec/classes/collectd_plugin_java_spec.rb b/spec/classes/collectd_plugin_java_spec.rb index ac2701b1..dc87a19c 100644 --- a/spec/classes/collectd_plugin_java_spec.rb +++ b/spec/classes/collectd_plugin_java_spec.rb @@ -118,7 +118,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context 'java_home option is empty' do it 'will not contain libjvm' do diff --git a/spec/classes/collectd_plugin_mcelog_spec.rb b/spec/classes/collectd_plugin_mcelog_spec.rb index 8cc47abb..7a2875f1 100644 --- a/spec/classes/collectd_plugin_mcelog_spec.rb +++ b/spec/classes/collectd_plugin_mcelog_spec.rb @@ -29,7 +29,7 @@ it { is_expected.to contain_file('mcelog.load').with(content: %r{PersistentNotification false}) } end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context 'on osfamily => RedHat' do it { is_expected.to contain_package('collectd-mcelog').with(ensure: 'present') } diff --git a/spec/classes/collectd_plugin_netlink_spec.rb b/spec/classes/collectd_plugin_netlink_spec.rb index cf53fff3..6c187c05 100644 --- a/spec/classes/collectd_plugin_netlink_spec.rb +++ b/spec/classes/collectd_plugin_netlink_spec.rb @@ -40,7 +40,7 @@ it { is_expected.to contain_file('netlink.load').with_content(%r{^ Filter "ppp0" "u32-1:0"$}) } it { is_expected.to contain_file('netlink.load').with_content(%r{^ IgnoreSelected false$}) } - it { is_expected.to contain_package('collectd-netlink').with(ensure: 'present') } if facts[:os]['family'] == 'RedHat' + it { is_expected.to contain_package('collectd-netlink').with(ensure: 'present') } if facts['os']['family'] == 'RedHat' end context ':ensure => absent' do @@ -55,7 +55,7 @@ ) end - if facts[:os]['family'] == 'RedHat' + if facts['os']['family'] == 'RedHat' it do is_expected.to contain_package('collectd-netlink').with( ensure: 'absent' diff --git a/spec/classes/collectd_plugin_ovs_events_spec.rb b/spec/classes/collectd_plugin_ovs_events_spec.rb index f1bc1c73..aae26f69 100644 --- a/spec/classes/collectd_plugin_ovs_events_spec.rb +++ b/spec/classes/collectd_plugin_ovs_events_spec.rb @@ -78,7 +78,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context 'on osfamily => RedHat' do it 'Will delete packaging config file' do diff --git a/spec/classes/collectd_plugin_ovs_stats_spec.rb b/spec/classes/collectd_plugin_ovs_stats_spec.rb index 0d5ef0b1..a35e0818 100644 --- a/spec/classes/collectd_plugin_ovs_stats_spec.rb +++ b/spec/classes/collectd_plugin_ovs_stats_spec.rb @@ -64,7 +64,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context 'on osfamily => RedHat' do it 'Will delete packaging config file' do diff --git a/spec/classes/collectd_plugin_processes_spec.rb b/spec/classes/collectd_plugin_processes_spec.rb index 9d60da36..7834f599 100644 --- a/spec/classes/collectd_plugin_processes_spec.rb +++ b/spec/classes/collectd_plugin_processes_spec.rb @@ -143,7 +143,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context 'on osfamily => RedHat' do it 'Will delete packaging config file' do diff --git a/spec/classes/collectd_plugin_rabbitmq_spec.rb b/spec/classes/collectd_plugin_rabbitmq_spec.rb index 63546f67..8f55956d 100644 --- a/spec/classes/collectd_plugin_rabbitmq_spec.rb +++ b/spec/classes/collectd_plugin_rabbitmq_spec.rb @@ -25,7 +25,7 @@ } end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8], %w[Ubuntu 20.04] it { is_expected.to raise_error(%r{does not support Python 3}) } else @@ -68,7 +68,7 @@ { custom_types_db: '/var/custom/types.db' } end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8], %w[Ubuntu 20.04] it { is_expected.to raise_error(%r{does not support Python 3}) } else @@ -83,7 +83,7 @@ { config: { 'Username' => 'foo' } } end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8], %w[Ubuntu 20.04] it { is_expected.to raise_error(%r{does not support Python 3}) } else @@ -98,7 +98,7 @@ { config: { 'Password' => 'foo' } } end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8], %w[Ubuntu 20.04] it { is_expected.to raise_error(%r{does not support Python 3}) } else @@ -113,7 +113,7 @@ { config: { 'Scheme' => 'https' } } end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8], %w[Ubuntu 20.04] it { is_expected.to raise_error(%r{does not support Python 3}) } else @@ -129,7 +129,7 @@ { ensure: 'absent' } end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8], %w[Ubuntu 20.04] it { is_expected.to raise_error(%r{does not support Python 3}) } else @@ -156,7 +156,7 @@ } end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8], %w[Ubuntu 20.04] it { is_expected.to raise_error(%r{does not support Python 3}) } else diff --git a/spec/classes/collectd_plugin_rrdtool_spec.rb b/spec/classes/collectd_plugin_rrdtool_spec.rb index 262d218a..6e2411b6 100644 --- a/spec/classes/collectd_plugin_rrdtool_spec.rb +++ b/spec/classes/collectd_plugin_rrdtool_spec.rb @@ -19,7 +19,7 @@ ) end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' it { is_expected.to contain_package('collectd-rrdtool').with(ensure: 'present') } diff --git a/spec/classes/collectd_plugin_smart_spec.rb b/spec/classes/collectd_plugin_smart_spec.rb index a64b8000..d6bef274 100644 --- a/spec/classes/collectd_plugin_smart_spec.rb +++ b/spec/classes/collectd_plugin_smart_spec.rb @@ -37,7 +37,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context ':manage_package => true on osfamily => RedHat' do let :params do diff --git a/spec/classes/collectd_plugin_virt_spec.rb b/spec/classes/collectd_plugin_virt_spec.rb index 5a53aae8..709906e7 100644 --- a/spec/classes/collectd_plugin_virt_spec.rb +++ b/spec/classes/collectd_plugin_virt_spec.rb @@ -96,7 +96,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context 'on osfamily => RedHat' do it 'Will delete packaging config file' do @@ -147,7 +147,7 @@ end end - case facts[:os]['family'] + case facts['os']['family'] when 'RedHat' context 'on osfamily => RedHat' do it 'Will delete packaging config file' do diff --git a/spec/classes/collectd_plugin_write_http_spec.rb b/spec/classes/collectd_plugin_write_http_spec.rb index 4a363694..eef7e745 100644 --- a/spec/classes/collectd_plugin_write_http_spec.rb +++ b/spec/classes/collectd_plugin_write_http_spec.rb @@ -33,7 +33,7 @@ ) end - case [facts[:os]['family'], facts[:os]['release']['major']] + case [facts['os']['family'], facts['os']['release']['major']] when %w[RedHat 8] it { is_expected.to contain_package('collectd-write_http') } else diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 46d4c7f1..2f99127a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,6 +9,10 @@ require 'voxpupuli/test/spec_helper' +RSpec.configure do |c| + c.facterdb_string_keys = true +end + add_mocked_facts! if File.exist?(File.join(__dir__, 'default_module_facts.yml')) diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb index b2557071..9595fa59 100644 --- a/spec/spec_helper_methods.rb +++ b/spec/spec_helper_methods.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true def os_specific_options(facts) - case facts[:os]['family'] + case facts['os']['family'] when 'Gentoo' { package: 'app-admin/collectd', service: 'collectd', plugin_conf_dir: '/etc/collectd.d' } when 'Solaris'