Mercurial > repos > other > Puppet
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 |
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 | 3 describe 'Root Home Specs' do |
4 describe Facter::Util::RootHome do | |
5 context 'when solaris' do | |
6 let(:root_ent) { 'root:x:0:0:Super-User:/:/sbin/sh' } | |
7 let(:expected_root_home) { '/' } | |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 |
272 | 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 | 11 expect(described_class.returnt_root_home).to eq(expected_root_home) |
12 end | |
13 end | |
14 context 'when linux' do | |
15 let(:root_ent) { 'root:x:0:0:root:/root:/bin/bash' } | |
16 let(:expected_root_home) { '/root' } | |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 |
272 | 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 | 20 expect(described_class.returnt_root_home).to eq(expected_root_home) |
21 end | |
22 end | |
23 context 'when windows' do | |
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 | 26 expect(described_class.returnt_root_home).to be_nil |
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 | 30 |
31 describe 'root_home', :type => :fact do | |
32 before(:each) { Facter.clear } | |
33 after(:each) { Facter.clear } | |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 |
272 | 35 context 'when macosx' do |
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 | 39 end |
40 let(:expected_root_home) { '/var/root' } | |
41 | |
42 sample_dscacheutil = File.read(fixtures('dscacheutil', 'root')) | |
43 | |
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 | 46 expect(Facter.fact(:root_home).value).to eq(expected_root_home) |
47 end | |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 end |
272 | 49 |
50 context 'when aix' do | |
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 | 54 end |
55 let(:expected_root_home) { '/root' } | |
56 | |
57 sample_lsuser = File.read(fixtures('lsuser', 'root')) | |
58 | |
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 | 61 expect(Facter.fact(:root_home).value).to eq(expected_root_home) |
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 |