|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +describe Facts::Solaris::Hypervisors::Ldom do |
| 4 | + describe '#call_the_resolver' do |
| 5 | + subject(:fact) { Facts::Solaris::Hypervisors::Ldom.new } |
| 6 | + |
| 7 | + before do |
| 8 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve) |
| 9 | + end |
| 10 | + |
| 11 | + context 'when Ldom resolver returns values' do |
| 12 | + let(:value) do |
| 13 | + { |
| 14 | + 'chassis_serial' => 'AK00358110', |
| 15 | + 'control_domain' => 'opdx-a0-sun2', |
| 16 | + 'domain_name' => 'sol11-9', |
| 17 | + 'domain_uuid' => 'd7a3a4df-ce8c-47a9-b396-cb5a5f30c0b2', |
| 18 | + 'role_control' => 'false', |
| 19 | + 'role_io' => 'false', |
| 20 | + 'role_root' => 'false', |
| 21 | + 'role_service' => 'false' |
| 22 | + } |
| 23 | + end |
| 24 | + |
| 25 | + before do |
| 26 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:chassis_serial).and_return('AK00358110') |
| 27 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:control_domain).and_return('opdx-a0-sun2') |
| 28 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:domain_name).and_return('sol11-9') |
| 29 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_control).and_return('false') |
| 30 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_io).and_return('false') |
| 31 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_root).and_return('false') |
| 32 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_service).and_return('false') |
| 33 | + allow(Facter::Resolvers::Solaris::Ldom) |
| 34 | + .to receive(:resolve) |
| 35 | + .with(:domain_uuid) |
| 36 | + .and_return('d7a3a4df-ce8c-47a9-b396-cb5a5f30c0b2') |
| 37 | + end |
| 38 | + |
| 39 | + it 'returns virtual fact as physical' do |
| 40 | + expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \ |
| 41 | + have_attributes(name: 'hypervisors.ldom', value: value) |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + context 'when ldom resolver returns nil' do |
| 46 | + before do |
| 47 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:chassis_serial).and_return(nil) |
| 48 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:control_domain).and_return(nil) |
| 49 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:domain_name).and_return(nil) |
| 50 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_control).and_return(nil) |
| 51 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_impl).and_return(nil) |
| 52 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_io).and_return(nil) |
| 53 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_root).and_return(nil) |
| 54 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:role_service).and_return(nil) |
| 55 | + allow(Facter::Resolvers::Solaris::Ldom).to receive(:resolve).with(:domain_uuid).and_return(nil) |
| 56 | + end |
| 57 | + |
| 58 | + context 'when role_control is false' do |
| 59 | + let(:value) do |
| 60 | + { |
| 61 | + 'chassis_serial' => nil, |
| 62 | + 'control_domain' => nil, |
| 63 | + 'domain_name' => nil, |
| 64 | + 'domain_uuid' => nil, |
| 65 | + 'role_control' => nil, |
| 66 | + 'role_io' => nil, |
| 67 | + 'role_root' => nil, |
| 68 | + 'role_service' => nil |
| 69 | + } |
| 70 | + end |
| 71 | + |
| 72 | + it 'returns virtual fact as physical' do |
| 73 | + expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \ |
| 74 | + have_attributes(name: 'hypervisors.ldom', value: value) |
| 75 | + end |
| 76 | + end |
| 77 | + end |
| 78 | + end |
| 79 | +end |
0 commit comments