Skip to content

Commit

Permalink
Merge pull request #742 from yast/network-ng-fixes
Browse files Browse the repository at this point in the history
Y2Network::Config.from fix
  • Loading branch information
imobachgs committed Mar 22, 2019
2 parents 0a4320c + c9a683b commit fc694b8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/lib/y2network/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ class Config
# @return [Symbol] Information source (see {Y2Network::Reader} and {Y2Network::Writer})
attr_reader :source

# @param source [Symbol] Source to read the configuration from
class << self
# @param source [Symbol] Source to read the configuration from
# @return [Y2Network::Config]
def from(source)
builder = ConfigReader.for(source)
builder.network_config
reader = ConfigReader.for(source)
reader.config
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/lib/y2network/config_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
module Y2Network
# This module contains a set of classes to read the network configuration from the system
#
# For the time being, only the wicked reader ({Y2Network::ConfigReader::Sysconfig}) reader is
# available.
# For the time being, only the wicked (through sysconfig files) reader
# ({Y2Network::ConfigReader::Sysconfig}) is available.
module ConfigReader
# Config reader for a given source
#
Expand Down
15 changes: 15 additions & 0 deletions test/y2network/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@

let(:routing_tables) { [table1, table2] }

describe ".from" do
let(:reader) do
instance_double(Y2Network::ConfigReader::Sysconfig, config: config)
end

before do
allow(Y2Network::ConfigReader).to receive(:for).with(:sysconfig)
.and_return(reader)
end

it "returns the configuration from the given reader" do
expect(described_class.from(:sysconfig)).to eq(config)
end
end

describe "#routes" do
it "returns routes from all tables" do
expect(config.routes).to eq([route1, route2])
Expand Down

0 comments on commit fc694b8

Please sign in to comment.