annotate modules/stdlib/spec/unit/facter/root_home_spec.rb @ 275:d9352a684e62

Mass update of modules to remove deprecation warnings
author IBBoard <dev@ibboard.co.uk>
date Sun, 26 Jan 2020 11:36:07 +0000
parents c42fb28cff86
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 require 'spec_helper'
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 require 'facter/root_home'
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
3 describe 'Root Home Specs' do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
4 describe Facter::Util::RootHome do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
5 context 'when solaris' do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
6 let(:root_ent) { 'root:x:0:0:Super-User:/:/sbin/sh' }
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
7 let(:expected_root_home) { '/' }
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
9 it 'returns /' do
275
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
10 expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent)
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
11 expect(described_class.returnt_root_home).to eq(expected_root_home)
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
12 end
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
13 end
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
14 context 'when linux' do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
15 let(:root_ent) { 'root:x:0:0:root:/root:/bin/bash' }
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
16 let(:expected_root_home) { '/root' }
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
18 it 'returns /root' do
275
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
19 expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent)
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
20 expect(described_class.returnt_root_home).to eq(expected_root_home)
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
21 end
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
22 end
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
23 context 'when windows' do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
24 it 'is nil on windows' do
275
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
25 expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(nil)
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
26 expect(described_class.returnt_root_home).to be_nil
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
27 end
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 end
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 end
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
30
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
31 describe 'root_home', :type => :fact do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
32 before(:each) { Facter.clear }
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
33 after(:each) { Facter.clear }
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
35 context 'when macosx' do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
36 before(:each) do
275
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
37 allow(Facter.fact(:kernel)).to receive(:value).and_return('Darwin')
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
38 allow(Facter.fact(:osfamily)).to receive(:value).and_return('Darwin')
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
39 end
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
40 let(:expected_root_home) { '/var/root' }
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
41
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
42 sample_dscacheutil = File.read(fixtures('dscacheutil', 'root'))
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
43
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
44 it 'returns /var/root' do
275
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
45 allow(Facter::Util::Resolution).to receive(:exec).with('dscacheutil -q user -a name root').and_return(sample_dscacheutil)
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
46 expect(Facter.fact(:root_home).value).to eq(expected_root_home)
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
47 end
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 end
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
49
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
50 context 'when aix' do
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
51 before(:each) do
275
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
52 allow(Facter.fact(:kernel)).to receive(:value).and_return('AIX')
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
53 allow(Facter.fact(:osfamily)).to receive(:value).and_return('AIX')
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
54 end
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
55 let(:expected_root_home) { '/root' }
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
56
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
57 sample_lsuser = File.read(fixtures('lsuser', 'root'))
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
58
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
59 it 'returns /root' do
275
d9352a684e62 Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 272
diff changeset
60 allow(Facter::Util::Resolution).to receive(:exec).with('lsuser -c -a home root').and_return(sample_lsuser)
272
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
61 expect(Facter.fact(:root_home).value).to eq(expected_root_home)
c42fb28cff86 Update to a newer Python module
IBBoard <dev@ibboard.co.uk>
parents: 37
diff changeset
62 end
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 end
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 end
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 end