Skip to content

Commit

Permalink
Merge product workflow during autosetup_upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Nov 25, 2021
1 parent ed15a2d commit 1b6231a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/lib/autoinstall/clients/inst_autosetup_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ def main
return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless)

Progress.NextStage

# configure general settings

#
# Set workflow variables
#
# Ensure that we clean product cache to avoid product from control (bsc#1156058)
AutoinstFunctions.reset_product
# Merging selected product (bsc#1192437)
AutoinstSoftware.merge_product(AutoinstFunctions.selected_product)

# configure general settings
general_section = Profile.current["general"] || {}
AutoinstGeneral.Import(general_section)
Builtins.y2milestone(
Expand Down
17 changes: 15 additions & 2 deletions test/lib/clients/inst_autosetup_upgrade_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
require "y2packager/resolvable"

describe Y2Autoinstallation::Clients::InstAutosetupUpgrade do
let(:product_name) { "sled" }
let(:profile) do
{
"general" => {},
"software" => {
"products" => ["sled"],
"products" => [product_name],
"patterns" => ["yast-devel"],
"packages" => ["vim"],
"remove-packages" => ["emacs"],
Expand All @@ -40,6 +41,10 @@
}
end

let(:product) do
Y2Packager::Product.new(name: product_name)
end

before do
allow(subject).to receive(:probe_storage)
allow(Yast::Packages).to receive(:Init)
Expand All @@ -56,6 +61,8 @@
allow(Yast::WFM).to receive(:SetLanguage)
allow(Yast::UI).to receive(:SetLanguage)
allow(Yast::AutoinstFunctions).to receive(:available_base_products).and_return([])
allow(Yast::AutoinstFunctions).to receive(:selected_product).and_return(product)
allow(Yast::AutoinstSoftware).to receive(:merge_product)
allow(Yast::Product).to receive(:FindBaseProducts).and_return([])
allow(Yast::ProductControl).to receive(:RunFrom).and_return(:next)
end
Expand All @@ -67,6 +74,12 @@
subject.main
end

it "merges the selected product workflow" do
expect(Yast::AutoinstSoftware).to receive(:merge_product).with(product)

subject.main
end

it "checks if upgrade is supported" do
Yast::RootPart.previousRootPartition = ""
Yast::RootPart.selectedRootPartition = "/dev/sda1"
Expand Down Expand Up @@ -96,7 +109,7 @@
end

it "install/removes patterns, products anad packages according to profile" do
expect(Yast::Pkg).to receive(:ResolvableInstall).with("sled", :product)
expect(Yast::Pkg).to receive(:ResolvableInstall).with(product_name, :product)
expect(Yast::Pkg).to receive(:ResolvableInstall).with("yast-devel", :pattern)
expect(Yast::Pkg).to receive(:ResolvableInstall).with("vim", :package)
expect(Yast::Pkg).to receive(:ResolvableRemove).with("emacs", :package)
Expand Down

0 comments on commit 1b6231a

Please sign in to comment.