Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle the case when the host has no facts at all (nil) #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/katello_attach_subscription/fact_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class FactAnalyzer
UNKNOWN = 'Unknown'.freeze

def self.system_type_from_facts(facts)
return unless facts.is_a?(Hash)

if (not facts['virt::host_type'].nil? and facts['virt::host_type'] != 'Not Applicable') or
(facts['virt::is_guest'] and facts['virt::is_guest'].to_s.downcase != 'false') or
facts['virt::uuid']
Expand Down
4 changes: 4 additions & 0 deletions test/fact_analyzer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def test_system_type_from_facts_empty
assert_nil KatelloAttachSubscription::FactAnalyzer.system_type_from_facts({})
end

def test_system_type_from_facts_nil
assert_nil KatelloAttachSubscription::FactAnalyzer.system_type_from_facts(nil)
end

def test_system_type_from_facts_virt_host_type_kvm
assert_equal 'Guest', KatelloAttachSubscription::FactAnalyzer.system_type_from_facts({'virt::host_type' => 'kvm'})
end
Expand Down