Skip to content

Commit

Permalink
ConfigReader uses NetworkInterfaces module
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Mar 19, 2019
1 parent e333cbe commit 0e3574b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/lib/y2network/config_reader/wicked.rb
Expand Up @@ -18,21 +18,21 @@
# find current contact information at www.suse.com.
require "y2network/config"

Yast.import "LanItems"
Yast.import "NetworkInterfaces"

module Y2Network
module ConfigReader
# This class reads the current configuration from the system
class Wicked
# @return [Y2Network::Config] Network configuration
def config
Yast::LanItems.Read
Yast::NetworkInterfaces.Read
Config.new(interfaces: interfaces)
end

def interfaces
# TODO: for the time being, we are just relying in the underlying stuff.
Yast::LanItems.current_device_names.map do |name|
Yast::NetworkInterfaces.List("").map do |name|
Y2Network::Interface.new(name)
end
end
Expand Down
11 changes: 5 additions & 6 deletions test/y2network/config_reader/wicked_test.rb
Expand Up @@ -22,18 +22,17 @@
describe Y2Network::ConfigReader::Wicked do
subject(:reader) { described_class.new }

let(:lan_items) do
let(:network_interfaces) do
instance_double(
Yast::LanItemsClass,
Read: nil,
current_device_names: ["lo", "eth0", "wlan0"]
Yast::NetworkInterfacesClass,
Read: nil,
List: ["lo", "eth0", "wlan0"]
)
end

describe "" do
before do
allow(Yast).to receive(:import).with("LanItems")
stub_const("Yast::LanItems", lan_items)
stub_const("Yast::NetworkInterfaces", network_interfaces)
end

it "returns a configuration including network devices" do
Expand Down

0 comments on commit 0e3574b

Please sign in to comment.