Skip to content

Commit

Permalink
Add unit test for unplugged interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Feb 19, 2020
1 parent 01c3623 commit 7a56673
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/y2network/interface_config_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def save
yast_config.add_or_update_connection_config(@connection_config)
# Assign the new added interface in case of a new connection for an
# unplugged one (bsc#1162679)
interface ||= find_interface
self.interface = find_interface unless interface

if interface.respond_to?(:custom_driver)
interface.custom_driver = driver_auto? ? nil : driver.name
Expand Down
13 changes: 13 additions & 0 deletions test/y2network/interface_config_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@
subject.save
end

context "when the new connection config is for an unplugged interface" do
subject(:config_builder) do
res = Y2Network::InterfaceConfigBuilder.for("eth")
res.name = "eth1"
res
end

it "assigns the added interface to the builder" do
subject.save
expect(subject.interface.name).to eq("eth1")
end
end

context "when interface was renamed" do
before do
subject.rename_interface("eth2")
Expand Down

0 comments on commit 7a56673

Please sign in to comment.