Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Feb 12, 2025
1 parent 39d1551 commit 67fe2fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 11 additions & 3 deletions test/y2network/presenters/interface_summary_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@
let(:interfaces) do
Y2Network::InterfacesCollection.new(
[
double(Y2Network::Interface, hardware: nil, name: "vlan1", firmware_configured?: false),
double(Y2Network::Interface, hardware: nil, name: "vlan1", firmware_configured?: false,
renaming_mechanism: :none),
double(Y2Network::Interface, hardware: double.as_null_object, name: "eth1",
firmware_configured?: false),
firmware_configured?: false, renaming_mechanism: :mac),
double(Y2Network::Interface, hardware: double.as_null_object, name: "eth0",
firmware_configured?: false)
firmware_configured?: false, renaming_mechanism: :bus_id)
]
)
end
Expand Down Expand Up @@ -87,6 +88,13 @@
end
end

context "when an interface is using some renaming mechanism" do
it "is shown in the summary" do
text = presenter.text
expect(text).to include("Renaming mechanism : </b>BusID")
end
end

context "when a remote IP address is configured" do
it "is shown in the summary" do
text = presenter.text
Expand Down
10 changes: 7 additions & 3 deletions test/y2network/widgets/interfaces_table_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

let(:eth0) do
instance_double(Y2Network::Interface, name: "eth0", hardware: hwinfo, old_name: "eth1",
firmware_configured_by: nil, firmware_configured?: false)
firmware_configured_by: nil, firmware_configured?: false, renaming_mechanism: naming)
end

let(:br0) do
instance_double(Y2Network::VirtualInterface, name: "br0", hardware: nil, old_name: nil,
firmware_configured_by: nil, firmware_configured?: false)
firmware_configured_by: nil, firmware_configured?: false, renaming_mechanism: :none)
end
let(:interfaces) { Y2Network::InterfacesCollection.new([eth0, br0]) }
let(:hwinfo) do
Expand All @@ -47,6 +47,7 @@

let(:mac) { "01:23:45:67:89:ab" }
let(:busid) { "0000:04:00.0" }
let(:naming) { :mac }
let(:link) { false }
let(:exists?) { true }
let(:connections) { Y2Network::ConnectionConfigsCollection.new([eth0_conn, br0_conn]) }
Expand Down Expand Up @@ -124,6 +125,7 @@

context "when there is no MAC address" do
let(:mac) { nil }
let(:naming) { :none }

it "does not include the MAC in the description" do
expect(description).to receive(:value=) do |text|
Expand All @@ -150,6 +152,8 @@
end

context "when there is no hardware information" do
let(:naming) { :none }

let(:exists?) { false }

it "sets the description with 'no hardware information' warning" do
Expand Down Expand Up @@ -186,7 +190,7 @@
context "when the device is configured by hardware" do
let(:eth0) do
instance_double(Y2Network::Interface, name: "eth0", hardware: hwinfo, old_name: "eth1",
firmware_configured_by: :redfish, firmware_configured?: true)
firmware_configured_by: :redfish, firmware_configured?: true, renaming_mechanism: naming)
end

it "shows which firmware extension configured the device in the description" do
Expand Down

0 comments on commit 67fe2fe

Please sign in to comment.