Skip to content

Commit

Permalink
Merge pull request #1065 from yast/network_service_use
Browse files Browse the repository at this point in the history
Add NetworkService.use method
  • Loading branch information
teclator committed Jun 22, 2020
2 parents 220e3aa + f1d2859 commit e7663eb
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
13 changes: 13 additions & 0 deletions library/network/src/modules/NetworkService.rb
Expand Up @@ -157,6 +157,19 @@ def disabled?

alias_method :is_disabled, :disabled?

# Choose the given backend as the one to be used
#
# @param name [Symbol] backend name
# @param [Boolean] return whether the given backend was selected or not
def use(name)
return false unless BACKENDS.key?(name)

Read()
@cached_name = name

true
end

def use_network_manager
Read()
@cached_name = :network_manager
Expand Down
40 changes: 40 additions & 0 deletions library/network/test/network_service_test.rb
Expand Up @@ -150,4 +150,44 @@
expect(subject.wicked?).to eq(true)
end
end

describe "#use" do
before do
allow(subject).to receive(:backend_in_use).and_return(:wicked)
subject.reset!
end

context "when the given backend is supported" do
it "ensures that the config is read before modifying it" do
expect(subject).to receive(:Read).and_call_original
subject.use(:network_manager)
end

it "changes the backend to the one given" do
expect { subject.use(:network_manager) }
.to change { subject.cached_name }.from(:wicked).to(:network_manager)
end

it "returns true" do
expect(subject.use(:wicked)).to eql(true)
end
end

context "when the given backend is not supported" do
it "does not try to read the current config" do
expect(subject).to_not receive(:Read)
subject.use(:not_supported)
end

it "does not modify the cached name" do
value = subject.cached_name
subject.use(:not_supported)
expect(subject.cached_name).to eql(value)
end

it "returns false" do
expect(subject.use(:not_supported)).to eql(false)
end
end
end
end
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Sun Jun 21 20:01:42 UTC 2020 - Knut Anderssen <kandersen@suse.com>

- Add a method to change the selection of the network backend to be
used (related to bsc#1172749)
- 4.3.9

-------------------------------------------------------------------
Thu Jun 18 15:23:54 UTC 2020 - Ladislav Slezák <lslezak@suse.cz>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.3.8
Version: 4.3.9
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit e7663eb

Please sign in to comment.