Skip to content

Commit

Permalink
Show an error when not installable product is found
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 5, 2017
1 parent c074a74 commit ad31997
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
30 changes: 22 additions & 8 deletions src/lib/y2packager/clients/inst_repositories_initialization.rb
Expand Up @@ -37,15 +37,22 @@ class InstRepositoriesInitialization
def main
textdomain "installation"

if init_installation_repositories
adjust_base_product_selection
:next
else
Yast::Popup.Message(
if !init_installation_repositories
Yast::Popup.Error(
_("Failed to initialize the software repositories.\nAborting the installation.")
)
:abort
return :abort
end

if products.empty?
Yast::Popup.Error(
_("Unable to find base products to install.\nAborting the installation.")
)
return :abort
end

adjust_base_product_selection
:next
end

private
Expand All @@ -71,8 +78,15 @@ def init_installation_repositories
#
# See https://github.com/yast/yast-packager/blob/7e1a0bbb90823b03c15d92f408036a560dca8aa3/src/modules/Packages.rb#L1876
def adjust_base_product_selection
products = Y2Packager::Product.available_base_products
products.each(&:restore) if products.size > 1
return unless products.size > 1
products.each(&:restore)
end

# Return base available products
#
# @return [Array<Y2Product>] Available base products
def products
@products ||= Y2Packager::Product.available_base_products
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2packager/product_reader.rb
Expand Up @@ -77,6 +77,7 @@ def self.available_products

def self.installation_package_mapping
installation_packages = Yast::Pkg.PkgQueryProvides("system-installation()")
log.info "Installation packages: #{installation_packages.inspect}"

mapping = {}
installation_packages.each do |list|
Expand Down
17 changes: 15 additions & 2 deletions test/lib/clients/inst_repositories_initialization_test.rb
Expand Up @@ -9,7 +9,7 @@
let(:success) { true }
let(:prod1) { instance_double(Y2Packager::Product) }
let(:prod2) { instance_double(Y2Packager::Product) }
let(:products) { [] }
let(:products) { [prod1] }

describe "#main" do
before do
Expand All @@ -36,7 +36,7 @@
end

it "shows an error" do
expect(Yast::Popup).to receive(:Message)
expect(Yast::Popup).to receive(:Error)
client.main
end
end
Expand All @@ -59,5 +59,18 @@
client.main
end
end

context "when no products are found" do
let(:products) { [] }

it "returns :abort" do
expect(client.main).to eq(:abort)
end

it "shows an error" do
expect(Yast::Popup).to receive(:Error)
client.main
end
end
end
end

0 comments on commit ad31997

Please sign in to comment.