Skip to content

Commit 7280c6c

Browse files
authored
Merge pull request #1277 from puppetlabs/cont-173/main/update_deprecated_facter
(CONT-173) - Updating deprecated facter instances
2 parents dc70216 + 8c9413d commit 7280c6c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/facter/root_home.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Facter::Util::RootHome
99
class << self
1010
# determines the root home directory
1111
def returnt_root_home
12-
root_ent = Facter::Util::Resolution.exec('getent passwd root')
12+
root_ent = Facter::Core::Execution.execute('getent passwd root')
1313
# The home directory is the sixth element in the passwd entry
1414
# If the platform doesn't have getent, root_ent will be nil and we should
1515
# return it straight away.
@@ -25,7 +25,7 @@ def returnt_root_home
2525
Facter.add(:root_home) do
2626
confine kernel: :darwin
2727
setcode do
28-
str = Facter::Util::Resolution.exec('dscacheutil -q user -a name root')
28+
str = Facter::Core::Execution.execute('dscacheutil -q user -a name root')
2929
hash = {}
3030
str.split("\n").each do |pair|
3131
key, value = pair.split(%r{:})
@@ -39,7 +39,7 @@ def returnt_root_home
3939
confine kernel: :aix
4040
root_home = nil
4141
setcode do
42-
str = Facter::Util::Resolution.exec('lsuser -c -a home root')
42+
str = Facter::Core::Execution.execute('lsuser -c -a home root')
4343
str&.split("\n")&.each do |line|
4444
next if %r{^#}.match?(line)
4545
root_home = line.split(%r{:})[1]

spec/unit/facter/root_home_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
let(:expected_root_home) { '/' }
1010

1111
it 'returns /' do
12-
expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent)
12+
expect(Facter::Core::Execution).to receive(:execute).with('getent passwd root').and_return(root_ent)
1313
expect(described_class.returnt_root_home).to eq(expected_root_home)
1414
end
1515
end
@@ -18,13 +18,13 @@
1818
let(:expected_root_home) { '/root' }
1919

2020
it 'returns /root' do
21-
expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent)
21+
expect(Facter::Core::Execution).to receive(:execute).with('getent passwd root').and_return(root_ent)
2222
expect(described_class.returnt_root_home).to eq(expected_root_home)
2323
end
2424
end
2525
context 'when windows' do
2626
it 'is nil on windows' do
27-
expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(nil)
27+
expect(Facter::Core::Execution).to receive(:execute).with('getent passwd root').and_return(nil)
2828
expect(described_class.returnt_root_home).to be_nil
2929
end
3030
end
@@ -44,7 +44,7 @@
4444
sample_dscacheutil = File.read(fixtures('dscacheutil', 'root'))
4545

4646
it 'returns /var/root' do
47-
allow(Facter::Util::Resolution).to receive(:exec).with('dscacheutil -q user -a name root').and_return(sample_dscacheutil)
47+
allow(Facter::Core::Execution).to receive(:execute).with('dscacheutil -q user -a name root').and_return(sample_dscacheutil)
4848
expect(Facter.fact(:root_home).value).to eq(expected_root_home)
4949
end
5050
end
@@ -59,7 +59,7 @@
5959
sample_lsuser = File.read(fixtures('lsuser', 'root'))
6060

6161
it 'returns /root' do
62-
allow(Facter::Util::Resolution).to receive(:exec).with('lsuser -c -a home root').and_return(sample_lsuser)
62+
allow(Facter::Core::Execution).to receive(:execute).with('lsuser -c -a home root').and_return(sample_lsuser)
6363
expect(Facter.fact(:root_home).value).to eq(expected_root_home)
6464
end
6565
end

0 commit comments

Comments
 (0)