Skip to content

Commit

Permalink
Merge pull request #344 from bastelfreak/facts
Browse files Browse the repository at this point in the history
Replace legacy facts
  • Loading branch information
bastelfreak authored Dec 12, 2024
2 parents 3080021 + c13dfcf commit 34f9ef5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/facter/yum_reboot_required.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'English'

Facter.add(:yum_reboot_required) do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
if File.exist?('/usr/bin/needs-restarting')
Facter::Core::Execution.execute('/usr/bin/needs-restarting --reboothint')
Expand Down
6 changes: 3 additions & 3 deletions lib/facter/yum_updates.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Facter.add('yum_package_updates') do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
yum_updates = []

Expand All @@ -18,14 +18,14 @@
end

Facter.add('yum_has_updates') do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
Facter.value(:yum_package_updates).any?
end
end

Facter.add('yum_updates') do
confine osfamily: 'RedHat'
confine 'os.family': 'RedHat'
setcode do
Facter.value(:yum_package_updates).length
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/facter/yum_package_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

describe 'on non-Redhat distro' do
before do
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Debian')
allow(Facter.fact('os.family')).to receive(:value).and_return('Debian')
end

it { is_expected.to be_nil }
end

describe 'on Redhat distro' do
before do
allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat')
allow(Facter.fact('os.family')).to receive(:value).and_return('Redhat')
allow(File).to receive(:executable?) # Stub all other calls
allow(File).to receive(:executable?).with('/usr/bin/yum').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('/usr/bin/yum --assumeyes --quiet --cacheonly list updates').and_return(yum_list_updates_result)
Expand Down

0 comments on commit 34f9ef5

Please sign in to comment.