Skip to content

Commit

Permalink
Merge pull request #837 from yast/mocked_force_restart_service
Browse files Browse the repository at this point in the history
Improved mock of NetworkService actions
  • Loading branch information
teclator committed Jun 14, 2019
2 parents a80fe64 + 13e24b3 commit 417a8ea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
8 changes: 8 additions & 0 deletions package/yast2-network.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Jun 14 13:14:05 UTC 2019 - Knut Anderssen <kanderssen@suse.com>

- boo#1138297
- Improve some mocking in NetworkService.activate_network_service
unit test which caused some test to fail randomly.
- 4.2.7

-------------------------------------------------------------------
Fri Jun 14 10:39:05 UTC 2019 - Knut Anderssen <kanderssen@suse.com>

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


Name: yast2-network
Version: 4.2.6
Version: 4.2.7
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
42 changes: 26 additions & 16 deletions test/lan_test.rb
Expand Up @@ -66,37 +66,47 @@
Yast.import "Stage"
Yast.import "NetworkService"

let(:force_restart) { false }
let(:installation) { false }

before do
allow(Yast::LanItems).to receive(:force_restart).and_return(force_restart)
allow(Yast::Stage).to receive(:normal).and_return(!installation)
allow(Yast::Stage).to receive(:initial).and_return(installation)
end

[0, 1].each do |linuxrc_usessh|
ssh_flag = linuxrc_usessh != 0

context format("when linuxrc %s usessh flag", ssh_flag ? "sets" : "doesn't set") do
before(:each) do
allow(Yast::Linuxrc)
.to receive(:usessh)
.and_return(ssh_flag)
allow(Yast::Linuxrc).to receive(:usessh).and_return(ssh_flag)
end

context "when asked in normal mode" do
before(:each) do
allow(Yast::Stage)
.to receive(:normal)
.and_return(true)
context "and a restart is not forced" do
it "tries to reload network service" do
expect(Yast::NetworkService)
.to receive(:ReloadOrRestart)

Yast::Lan.send(:activate_network_service)
end
end

it "tries to reload network service" do
expect(Yast::NetworkService)
.to receive(:ReloadOrRestart)
context "and a restart is forced" do
let(:force_restart) { true }

Yast::Lan.send(:activate_network_service)
it "tries to restart the network service" do
expect(Yast::NetworkService)
.to receive(:Restart)

Yast::Lan.send(:activate_network_service)
end
end
end

context "when asked during installation" do
before(:each) do
allow(Yast::Stage)
.to receive(:normal)
.and_return(false)
end
let(:installation) { true }

it "updates network service according usessh flag" do
if ssh_flag
Expand Down

0 comments on commit 417a8ea

Please sign in to comment.