Skip to content

Commit

Permalink
Merge pull request #1272 from yast/fix_description_for_s390
Browse files Browse the repository at this point in the history
Fix description for s390 Group Device description
  • Loading branch information
teclator committed Nov 11, 2021
2 parents 039ad1d + e3d2e62 commit 14386d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
7 changes: 7 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Nov 10 21:41:54 UTC 2021 - Knut Anderssen <kanderssen@suse.com>

- Fixed interfaces table description for s390 Group devices
(bsc#1192560).
- 4.2.109

-------------------------------------------------------------------
Wed Nov 10 16:45:32 UTC 2021 - José Iván López González <jlopez@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-network.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.2.108
Version: 4.2.109
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
12 changes: 6 additions & 6 deletions src/lib/y2network/widgets/interfaces_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def note(interface, conn)

# Constructs device description for inactive s390 devices
def device_item(device)
[device.id, description_for(device.interface), _("Not activated"), device.id, ""]
[device.id, description_for(device), _("Not activated"), device.id, ""]
end

# Generic device description handler
Expand Down Expand Up @@ -142,17 +142,17 @@ def create_description
summary.new(value, config).text
end

# Returns the connection description if given or the interface friendly name if not
# Returns the connection description if given or the device friendly name if not
#
# @param interface [Interface] Network interface
# @param device [Interface, S390GroupDevice] Network device
# @param conn [ConnectionConfig::Base, nil] Connection configuration
# @return [String] Connection description if given or the friendly name for the interface (
# description or name) if not
def description_for(interface, conn)
def description_for(device, conn = nil)
return conn.description unless conn&.description.to_s.empty?

hwinfo = interface.hardware
(hwinfo&.present?) ? hwinfo.description : interface.name
hwinfo = device.hardware
(hwinfo&.present?) ? hwinfo.description : device.name
end

def summary_class_name
Expand Down
21 changes: 18 additions & 3 deletions test/y2network/widgets/interfaces_table_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
instance_double(Y2Network::Hwinfo, link: link, mac: mac, busid: busid,
exists?: exists?, present?: true, description: "Cool device", name: "Cool device")
end

let(:mac) { "01:23:45:67:89:ab" }
let(:busid) { "0000:04:00.0" }
let(:link) { false }
Expand All @@ -53,9 +54,24 @@
Y2Network::ConnectionConfig::Bridge.new.tap { |c| c.name = "br0" }
end

let(:qeth_0700) do
instance_double(Y2Network::S390GroupDevice, type: "qeth", hardware: hwinfo_0700,
id: "0.0.0700:0.0.0701:0.0.0702", online?: false)
end

let(:hwinfo_0700) do
instance_double(Y2Network::Hwinfo, present?: true,
description: "OSA Express Network card (0.0.0700)")
end

let(:s390_devices) do
Y2Network::S390GroupDevicesCollection.new([qeth_0700])
end

before do
allow(Yast::Lan).to receive(:yast_config)
.and_return(double(interfaces: interfaces, connections: connections, s390_devices: []))
.and_return(double(interfaces: interfaces, connections: connections, s390_devices:
s390_devices))
allow(Yast::UI).to receive(:QueryWidget).and_return([])
allow(subject).to receive(:value).and_return("eth0")
end
Expand Down Expand Up @@ -87,10 +103,9 @@

it "shows the hwinfo interface description if present or the interface name if not" do
expect(subject.items).to include(a_collection_including(/Cool device/, /eth0/),
a_collection_including(/br0/))
a_collection_including(/br0/), a_collection_including(/OSA Express Network card/))
end
end

end

describe "#handle" do
Expand Down

0 comments on commit 14386d4

Please sign in to comment.