Skip to content

Commit

Permalink
Added restarting state to Installation.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Apr 22, 2016
1 parent 01c4e8e commit ac033ed
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
7 changes: 4 additions & 3 deletions src/lib/installation/clients/inst_complex_welcome.rb
Expand Up @@ -42,8 +42,10 @@ def main

textdomain "installation"

@license_id = Ops.get(Pkg.SourceGetCurrent(true), 0, 0)

# ------------------------------------- main part of the client -----------
if data_stored? && !GetInstArgs.going_back
if Installation.restarting? && data_stored?
apply_data
return :next
end
Expand All @@ -53,8 +55,6 @@ def main
@language = Language.language
@keyboard = ""

@license_id = Ops.get(Pkg.SourceGetCurrent(true), 0, 0)

# ----------------------------------------------------------------------
# Build dialog
# ----------------------------------------------------------------------
Expand Down Expand Up @@ -374,6 +374,7 @@ def apply_data
@language = data["language"]
@keyboard = data["keyboard"]
@license_accepted = data["license_accepted"]
ProductLicense.info_seen!(@license_id)

change_language
setup_final_choice
Expand Down
4 changes: 1 addition & 3 deletions src/lib/installation/clients/inst_disks_activate.rb
Expand Up @@ -58,9 +58,7 @@ def main
@have_zfcp = false
@want_fcoe = false

@installer_update ||= InstUpdateInstaller.new

return :next if !GetInstArgs.going_back && @installer_update.installer_updated?
return :next if Installation.restarting?

if Arch.s390
# popup label
Expand Down
6 changes: 4 additions & 2 deletions src/lib/installation/clients/inst_update_installer.rb
Expand Up @@ -40,14 +40,16 @@ def main
textdomain "installation"

return :back if GetInstArgs.going_back

Installation.finish_restarting! if Installation.restarting?

return :next unless try_to_update?

log.info("Trying installer update")

if update_installer
::FileUtils.touch(update_flag_file) # Indicates that the installer was updated.
::FileUtils.touch(Installation.restart_file)
:restart_yast # restart YaST to apply modifications.
Installation.restart!
else
:next
end
Expand Down
19 changes: 16 additions & 3 deletions test/inst_complex_welcome_test.rb
Expand Up @@ -13,13 +13,15 @@

before do
stub_const("Yast::InstComplexWelcomeClient::DATA_PATH", store_path)
allow(Yast::ProductLicense).to receive(:info_seen?) { true }
end

after do
FileUtils.rm(store_path) if File.exist?(store_path)
end

describe "#main" do
let(:restarting) { false }
context "when installation Mode is auto" do
it "returns :auto" do
expect(Yast::Mode).to receive(:autoinst) { true }
Expand All @@ -31,18 +33,29 @@
context "when installation mode is not auto" do
before do
expect(Yast::Mode).to receive(:autoinst) { false }
allow(Yast::Installation).to receive(:restarting?) { restarting }
end

context "and previous data exist" do
it "applies data and returns :next" do
context "and installer is restarting" do
let(:restarting) { true }
it "applies data if exists and returns next" do
allow(subject).to receive(:data_stored?) { true }
expect(subject).to receive(:apply_data)

expect(subject.main).to eql(:next)
end

it "does not apply data if not exists and continues as not restarting" do
allow(subject).to receive(:data_stored?) { false }
expect(subject).not_to receive(:apply_data)
allow(subject).to receive(:event_loop)
expect(subject).to receive(:initialize_dialog)

subject.main
end
end

context "and no previous data exist" do
context "and installer is not restarting" do
before do
allow(subject).to receive(:data_stored?) { false }
end
Expand Down
10 changes: 4 additions & 6 deletions test/inst_disks_activate_test.rb
Expand Up @@ -15,23 +15,21 @@
describe "#main" do
let(:probed_disks) { [] }
let(:s390) { false }
let(:installer) { double("update_installer", installer_updated?: false) }
let(:going_back) { false }
let(:restarting) { false }

before do
allow(Yast::Linuxrc).to receive(:InstallInf).with("WithFCoE").and_return("0")
allow(Yast::UI).to receive(:OpenDialog)
allow(Yast::UI).to receive(:CloseDialog)
allow(Yast::Popup).to receive(:ConfirmAbort).with(:painless).and_return(true)
allow(Yast::Arch).to receive(:s390).and_return(s390)
allow(Yast::InstUpdateInstaller).to receive(:new).and_return(installer)
allow(Yast::GetInstArgs).to receive(:going_back) { going_back }
allow(Yast::Installation).to receive(:restarting?) { restarting }
stub_const("Yast::Storage", double("Yast::Storage", ReReadTargetMap: true))
end

context "when installer had been updated and not coming from other dialog" do
let(:installer) { double("update_installer", installer_updated?: true) }

context "when installation is restarting" do
let(:restarting) { true }
it "returns next" do
expect(Yast::Arch).to_not receive(:s390)

Expand Down
4 changes: 3 additions & 1 deletion test/inst_update_installer_test.rb
Expand Up @@ -23,6 +23,8 @@
allow(Yast::Mode).to receive(:auto).and_return(false)
allow(Yast::NetworkService).to receive(:isNetworkRunning).and_return(network_running)
allow(::Installation::UpdatesManager).to receive(:new).and_return(manager)
allow(Yast::Installation).to receive(:restarting?)
allow(Yast::Installation).to receive(:restart!) { :restart_yast }

# stub the Profile module to avoid dependency on autoyast2-installation
ay_profile = double("Yast::Profile")
Expand Down Expand Up @@ -51,7 +53,7 @@
end

it "creates update file and returns :restart_yast" do
expect(::FileUtils).to receive(:touch).twice
expect(::FileUtils).to receive(:touch).once
allow(subject).to receive(:self_update_enabled?).and_return(true)
expect(subject.main).to eq(:restart_yast)
end
Expand Down

0 comments on commit ac033ed

Please sign in to comment.