Skip to content

Commit

Permalink
Improve NetworkAutoYast#configure_lan test
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Apr 23, 2019
1 parent 3afdb94 commit 3bba385
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
36 changes: 35 additions & 1 deletion test/network_autoyast_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,14 @@ def mock_lan_item(renamed_to: nil)

describe "#configure_lan" do
before do
allow(Yast::Profile).to receive(:current).and_return("general" => general_section)
allow(Yast::Profile).to receive(:current)
.and_return("general" => general_section, "networking" => networking_section)
allow(Yast::AutoInstall).to receive(:valid_imported_values).and_return(true)
end

let(:networking_section) { nil }
let(:general_section) { nil }

context "when second stage is disabled" do
let(:general_section) do
{ "mode" => { "second_stage" => false } }
Expand All @@ -530,6 +534,13 @@ def mock_lan_item(renamed_to: nil)
end
end

context "when writing the configuration is disabled" do
it "writes the Lan module configuration" do
expect(Yast::Lan).to_not receive(:Write)
subject.configure_lan(write: false)
end
end

context "when second stage is enabled" do
let(:general_section) do
{ "mode" => { "second_stage" => true } }
Expand All @@ -549,5 +560,28 @@ def mock_lan_item(renamed_to: nil)
subject.configure_lan
end
end

it "merges the installation configuration" do
expect(Yast::NetworkAutoYast.instance).to receive(:merge_configs)
subject.configure_lan
end

context "when the user wants to keep the installation network" do
let(:networking_section) { { "keep_install_network" => true } }

it "merges the installation configuration" do
expect(Yast::NetworkAutoYast.instance).to receive(:merge_configs)
subject.configure_lan
end
end

context "when the user does not want to keep the installation network" do
let(:networking_section) { { "keep_install_network" => false } }

it "does not merge the installation configuration" do
expect(Yast::NetworkAutoYast.instance).to_not receive(:merge_configs)
subject.configure_lan
end
end
end
end
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def stub_module(name)

# stub classes from other modules to speed up a build
stub_module("AutoInstall")
stub_module("Profile")

# A two level section/key => value store
# to remember values of /etc/sysconfig/network/ifcfg-*
Expand Down

0 comments on commit 3bba385

Please sign in to comment.