Skip to content

Commit 67faa98

Browse files
bastelfreakekohl
authored andcommitted
Replace legacy facts in rspec tests
1 parent 3c8dfa9 commit 67faa98

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

spec/acceptance/puppetserver_upgrade_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
raise 'Unsupported Puppet collection'
2626
end
2727

28-
case fact('osfamily')
28+
case fact('os.family')
2929
when 'Debian'
3030
from_version_exact = "#{from_version}-1#{fact('os.distro.codename')}"
3131
to_version_exact = "#{to_version}-1#{fact('os.distro.codename')}"

spec/classes/puppet_agent_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe 'puppet' do
44
on_supported_os.each do |os, facts|
55
context "on #{os}" do
6-
case facts[:osfamily]
6+
case facts[:os]['family']
77
when 'FreeBSD'
88
puppet_major = facts[:puppetversion].to_i
99

@@ -41,7 +41,7 @@
4141

4242
describe 'with no custom parameters' do
4343
# For windows we specify a package provider which doesn't compile
44-
if facts[:osfamily] != 'windows'
44+
if facts[:os]['family'] != 'windows'
4545
it { is_expected.to compile.with_all_deps }
4646
end
4747

@@ -343,7 +343,7 @@
343343
end
344344

345345
# For windows we specify a package provider which doesn't compile
346-
if facts[:osfamily] != 'windows'
346+
if facts[:os]['family'] != 'windows'
347347
it { is_expected.to compile.with_all_deps }
348348
end
349349
it { is_expected.to contain_class('puppet::agent::service::daemon').with_enabled(false) }
@@ -364,7 +364,7 @@
364364
end
365365

366366
# For windows we specify a package provider which doesn't compile
367-
if facts[:osfamily] != 'windows'
367+
if facts[:os]['family'] != 'windows'
368368
it { is_expected.to compile.with_all_deps }
369369
end
370370
it { is_expected.to contain_class('puppet::agent::service::daemon').with_enabled(false) }

spec/classes/puppet_config_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe 'puppet' do
44
on_supported_os.each do |os, os_facts|
55
context "on #{os}" do
6-
case os_facts[:osfamily]
6+
case os_facts[:os]['family']
77
when 'FreeBSD'
88
dir_owner = 'root'
99
dir_group = nil

spec/classes/puppet_init_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe 'puppet' do
44
on_supported_os.each do |os, facts|
55
context "on #{os}" do
6-
case facts[:osfamily]
6+
case facts[:os]['family']
77
when 'FreeBSD'
88
puppet_major = facts[:puppetversion].to_i
99

@@ -33,7 +33,7 @@
3333
end
3434

3535
describe 'with no custom parameters' do
36-
it { is_expected.to compile.with_all_deps unless facts[:osfamily] == 'windows' }
36+
it { is_expected.to compile.with_all_deps unless facts[:os]['family'] == 'windows' }
3737
it { should contain_class('puppet::agent') }
3838
it { should contain_class('puppet::config') }
3939
it { should_not contain_class('puppet::server') }
@@ -45,7 +45,7 @@
4545
}
4646
end
4747

48-
describe 'with server => true', :unless => unsupported_puppetserver_osfamily(facts[:osfamily]) do
48+
describe 'with server => true', :unless => unsupported_puppetserver_osfamily(facts[:os]['family']) do
4949
let :params do {
5050
:server => true,
5151
} end
@@ -112,7 +112,7 @@
112112
end
113113

114114
# compilation is broken due to paths
115-
context 'on non-windows', unless: facts[:osfamily] == 'windows' do
115+
context 'on non-windows', unless: facts[:os]['family'] == 'windows' do
116116
describe 'with package_source => Httpurl' do
117117
let :params do {
118118
:package_source => 'https://example.com:123/test'

spec/classes/puppet_server_puppetdb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe 'puppet::server::puppetdb' do
44
on_supported_os.each do |os, os_facts|
5-
context "on #{os}", unless: unsupported_puppetserver_osfamily(os_facts[:osfamily]) do
5+
context "on #{os}", unless: unsupported_puppetserver_osfamily(os_facts[:os]['family']) do
66
let(:facts) { os_facts }
77
let(:params) { {server: 'mypuppetdb.example.com'} }
88
let(:pre_condition) do

spec/classes/puppet_server_puppetserver_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
describe 'puppet' do
55
on_supported_os.each do |os, facts|
6-
next if unsupported_puppetserver_osfamily(facts[:osfamily])
6+
next if unsupported_puppetserver_osfamily(facts[:os]['family'])
77
context "on #{os}" do
88
let(:facts) do
99
facts
@@ -26,7 +26,7 @@
2626
end
2727

2828
let(:server_vardir) do
29-
if ['FreeBSD', 'DragonFly'].include?(facts[:operatingsystem])
29+
if ['FreeBSD', 'DragonFly'].include?(facts[:os]['name'])
3030
'/var/puppet/server/data/puppetserver'
3131
else
3232
'/opt/puppetlabs/server/data/puppetserver'
@@ -41,7 +41,7 @@
4141
.with_content(%r{^#puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service})
4242
.with_content(%r{^puppetlabs.trapperkeeper.services.watcher.filesystem-watch-service/filesystem-watch-service})
4343
}
44-
if facts[:osfamily] == 'FreeBSD'
44+
if facts[:os]['family'] == 'FreeBSD'
4545
it {
4646
should contain_augeas('puppet::server::puppetserver::jvm')
4747
.with_changes(['set puppetserver_java_opts \'"-Xms2G -Xmx2G"\''])
@@ -343,10 +343,10 @@
343343
end
344344
end
345345

346-
describe 'server_max_open_files', unless: facts[:osfamily] == 'FreeBSD' do
346+
describe 'server_max_open_files', unless: facts[:os]['family'] == 'FreeBSD' do
347347
context 'when server_max_open_files => undef' do
348348
it do
349-
if facts['service_provider'] == 'systemd'
349+
if facts[:service_provider] == 'systemd'
350350
should contain_systemd__dropin_file('puppetserver.service-limits.conf')
351351
.with_ensure('absent')
352352
else
@@ -360,7 +360,7 @@
360360
let(:params) { super().merge(server_max_open_files: 32143) }
361361

362362
it do
363-
if facts['service_provider'] == 'systemd'
363+
if facts[:service_provider] == 'systemd'
364364
should contain_systemd__dropin_file('puppetserver.service-limits.conf')
365365
.with_ensure('present')
366366
.with_filename('limits.conf')
@@ -379,7 +379,7 @@
379379

380380
describe 'with extra_args parameter' do
381381
let(:params) { super().merge(server_jvm_extra_args: ['-XX:foo=bar', '-XX:bar=foo']) }
382-
if facts[:osfamily] == 'FreeBSD'
382+
if facts[:os]['family'] == 'FreeBSD'
383383
it {
384384
should contain_augeas('puppet::server::puppetserver::jvm')
385385
.with_changes(['set puppetserver_java_opts \'"-Xms2G -Xmx2G -XX:foo=bar -XX:bar=foo"\''])
@@ -410,7 +410,7 @@
410410
end
411411
end
412412

413-
describe 'with cli_args parameter', unless: facts[:osfamily] == 'FreeBSD' do
413+
describe 'with cli_args parameter', unless: facts[:os]['family'] == 'FreeBSD' do
414414
let(:params) { super().merge(server_jvm_cli_args: '-Djava.io.tmpdir=/var/puppettmp') }
415415
if facts[:os]['family'] == 'RedHat'
416416
it {
@@ -441,7 +441,7 @@
441441

442442
describe 'with jvm_config file parameter' do
443443
let(:params) { super().merge(server_jvm_config: '/etc/custom/puppetserver') }
444-
if facts[:osfamily] == 'FreeBSD'
444+
if facts[:os]['family'] == 'FreeBSD'
445445
it { should contain_augeas('puppet::server::puppetserver::jvm').with_context('/files/etc/rc.conf') }
446446
else
447447
it do
@@ -454,7 +454,7 @@
454454
end
455455

456456
describe 'gem-path' do
457-
if ['FreeBSD', 'DragonFly'].include?(facts[:osfamily])
457+
if ['FreeBSD', 'DragonFly'].include?(facts[:os]['family'])
458458
it do
459459
should contain_file(puppetserver_conf)
460460
.with_content(%r{^ gem-path: \[\$\{jruby-puppet.gem-home\}, "#{server_vardir}/vendored-jruby-gems", "#{facts[:ruby]['sitedir'].sub(/site_ruby/,'gems')}"\]$})

spec/classes/puppet_server_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
describe 'puppet' do
44
on_supported_os.each do |os, facts|
5-
context "on #{os}", unless: unsupported_puppetserver_osfamily(facts[:osfamily]) do
6-
if facts[:osfamily] == 'FreeBSD'
5+
context "on #{os}", unless: unsupported_puppetserver_osfamily(facts[:os]['family']) do
6+
if facts[:os]['family'] == 'FreeBSD'
77
codedir = '/usr/local/etc/puppet'
88
confdir = '/usr/local/etc/puppet'
99
etcdir = '/usr/local/etc/puppet'
@@ -339,7 +339,7 @@
339339
end
340340

341341
it 'should create the puppet user' do
342-
shell = case facts[:osfamily]
342+
shell = case facts[:os]['family']
343343
when /^(FreeBSD|DragonFly)$/
344344
'/usr/local/bin/git-shell'
345345
else

0 commit comments

Comments
 (0)