Sha256: cadca234c65c504ea4285698bb6c19bb24b2926c3dddaedb73d2da9e57fb99f8

Contents?: true

Size: 1.6 KB

Versions: 52

Compression:

Stored size: 1.6 KB

Contents

require_relative '../test_plugin_helper'

class LldpNeighborsTest < ActiveSupport::TestCase
  test "#get_neighbors_by_interface gives nothing with no LLDP facts" do
    assert_nil simple_facts.get_neighbors_by_interface('eth0')
  end

  test "#get_neighbors_by_interface gives nothing with unmatching PVID in LLDP facts" do
    assert_nil lldp_facts.get_neighbors_by_interface('eth0')
  end

  test "#get_neighbors_by_interface gives a valid pair for LLDP facts with matching PVID" do
    assert_equal %w(eth0 eth1), bond_facts.get_neighbors_by_interface('eth0')
    assert_equal %w(eth0 eth1), bond_facts.get_neighbors_by_interface('eth1')
    assert_nil bond_facts.get_neighbors_by_interface('br182')
  end

  test "#list_by_pvid gives an empty Hash without LLDP facts" do
    assert_equal({}, simple_facts.list_by_pvid)
    assert_equal({}, ForemanDiscovery::LldpNeighbors.from_facts({}).list_by_pvid)
  end

  test "#list_by_pvid gives an empty Hash without LLDP facts" do
    assert_equal({'182' => %w(eth2), '184' => %w(eth1)}, lldp_facts.list_by_pvid)
  end

  test "#list_by_pvid pairs interfaces by PVID" do
    assert_equal({'182' => %w(eth0 eth1)}, bond_facts.list_by_pvid)
  end

  test "#list_by_pvid supports multiple PVIDs" do
    assert_equal({'182' => %w(eth2), '184' => %w(eth1)}, lldp_facts.list_by_pvid)
  end

  private

  def simple_facts
    neighbors 'regular_host'
  end

  def lldp_facts
    neighbors 'facts_with_lldp'
  end

  def bond_facts
    neighbors 'facts_with_lldp_bond_candidate'
  end

  def neighbors(name)
    ForemanDiscovery::LldpNeighbors.from_facts(parse_json_fixture(name, true))
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
foreman_discovery-25.0.1 test/unit/lldp_neighbors_test.rb
foreman_discovery-25.0.0 test/unit/lldp_neighbors_test.rb
foreman_discovery-24.0.2 test/unit/lldp_neighbors_test.rb
foreman_discovery-23.0.2 test/unit/lldp_neighbors_test.rb
foreman_discovery-24.0.1 test/unit/lldp_neighbors_test.rb
foreman_discovery-24.0.0 test/unit/lldp_neighbors_test.rb
foreman_discovery-23.0.1 test/unit/lldp_neighbors_test.rb
foreman_discovery-23.0.0 test/unit/lldp_neighbors_test.rb
foreman_discovery-22.0.4 test/unit/lldp_neighbors_test.rb
foreman_discovery-21.0.5 test/unit/lldp_neighbors_test.rb
foreman_discovery-22.0.2 test/unit/lldp_neighbors_test.rb
foreman_discovery-21.0.4 test/unit/lldp_neighbors_test.rb
foreman_discovery-21.0.3 test/unit/lldp_neighbors_test.rb
foreman_discovery-21.0.2 test/unit/lldp_neighbors_test.rb
foreman_discovery-19.0.5 test/unit/lldp_neighbors_test.rb
foreman_discovery-19.0.4 test/unit/lldp_neighbors_test.rb
foreman_discovery-21.0.1 test/unit/lldp_neighbors_test.rb
foreman_discovery-19.0.3 test/unit/lldp_neighbors_test.rb
foreman_discovery-21.0.0 test/unit/lldp_neighbors_test.rb
foreman_discovery-19.0.2 test/unit/lldp_neighbors_test.rb