Hello community, here is the log from the commit of package yast2-packager for openSUSE:Factory checked in at 2016-04-28 20:30:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-packager (Old) and /work/SRC/openSUSE:Factory/.yast2-packager.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-packager" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-packager/yast2-packager.changes 2016-04-11 09:12:44.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-packager.new/yast2-packager.changes 2016-04-28 20:30:38.000000000 +0200 @@ -1,0 +2,24 @@ +Fri Apr 22 16:23:17 UTC 2016 - lslezak@suse.cz + +- Move the default pattern selection to a different place to not + conflict with the pattern selection in the system upgrade mode + (FATE#320199) +- 3.1.97 + +------------------------------------------------------------------- +Fri Apr 22 11:48:52 UTC 2016 - knut.anderssen@suse.com + +- Added public methods to modify and know info about files read, + in this case to avoid display the welcome dialog again after + restart yast (bsc#974409) +- 3.1.96 + +------------------------------------------------------------------- +Mon Apr 11 17:35:17 UTC 2016 - lslezak@suse.cz + +- Select the default product patterns defined by the + 'defaultpattern()' provides in the initial installation + (FATE#320199) +- 3.1.95 + +------------------------------------------------------------------- Old: ---- yast2-packager-3.1.94.tar.bz2 New: ---- yast2-packager-3.1.97.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-packager.spec ++++++ --- /var/tmp/diff_new_pack.WGlD0R/_old 2016-04-28 20:30:40.000000000 +0200 +++ /var/tmp/diff_new_pack.WGlD0R/_new 2016-04-28 20:30:40.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-packager -Version: 3.1.94 +Version: 3.1.97 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -122,8 +122,10 @@ %defattr(-,root,root) %dir %{yast_yncludedir}/checkmedia %dir %{yast_yncludedir}/packager +%dir %{yast_libdir}/packager %{yast_yncludedir}/checkmedia/* %{yast_yncludedir}/packager/* +%{yast_libdir}/packager/* %{yast_clientdir}/*.rb %{yast_moduledir}/* %{yast_desktopdir}/*.desktop ++++++ yast2-packager-3.1.94.tar.bz2 -> yast2-packager-3.1.97.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/package/yast2-packager.changes new/yast2-packager-3.1.97/package/yast2-packager.changes --- old/yast2-packager-3.1.94/package/yast2-packager.changes 2016-04-06 14:52:57.000000000 +0200 +++ new/yast2-packager-3.1.97/package/yast2-packager.changes 2016-04-25 11:47:26.000000000 +0200 @@ -1,4 +1,28 @@ ------------------------------------------------------------------- +Fri Apr 22 16:23:17 UTC 2016 - lslezak@suse.cz + +- Move the default pattern selection to a different place to not + conflict with the pattern selection in the system upgrade mode + (FATE#320199) +- 3.1.97 + +------------------------------------------------------------------- +Fri Apr 22 11:48:52 UTC 2016 - knut.anderssen@suse.com + +- Added public methods to modify and know info about files read, + in this case to avoid display the welcome dialog again after + restart yast (bsc#974409) +- 3.1.96 + +------------------------------------------------------------------- +Mon Apr 11 17:35:17 UTC 2016 - lslezak@suse.cz + +- Select the default product patterns defined by the + 'defaultpattern()' provides in the initial installation + (FATE#320199) +- 3.1.95 + +------------------------------------------------------------------- Wed Apr 6 09:57:59 UTC 2016 - knut.anderssen@suse.com - Explicitly resolve shortcut conflicts proposing 'alt-w' for diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/package/yast2-packager.spec new/yast2-packager-3.1.97/package/yast2-packager.spec --- old/yast2-packager-3.1.94/package/yast2-packager.spec 2016-04-06 14:52:57.000000000 +0200 +++ new/yast2-packager-3.1.97/package/yast2-packager.spec 2016-04-25 11:47:26.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-packager -Version: 3.1.94 +Version: 3.1.97 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -121,8 +121,10 @@ %defattr(-,root,root) %dir %{yast_yncludedir}/checkmedia %dir %{yast_yncludedir}/packager +%dir %{yast_libdir}/packager %{yast_yncludedir}/checkmedia/* %{yast_yncludedir}/packager/* +%{yast_libdir}/packager/* %{yast_clientdir}/*.rb %{yast_moduledir}/* %{yast_desktopdir}/*.desktop diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/src/Makefile.am new/yast2-packager-3.1.97/src/Makefile.am --- old/yast2-packager-3.1.94/src/Makefile.am 2016-04-06 14:52:57.000000000 +0200 +++ new/yast2-packager-3.1.97/src/Makefile.am 2016-04-25 11:47:26.000000000 +0200 @@ -51,6 +51,9 @@ include/packager/load_release_notes.rb \ include/packager/repositories_include.rb +ylibdir = @ylibdir@/packager +ylib_DATA = lib/packager/product_patterns.rb + ynclude1dir = @yncludedir@/checkmedia ynclude1_DATA = \ include/checkmedia/ui.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/src/lib/packager/product_patterns.rb new/yast2-packager-3.1.97/src/lib/packager/product_patterns.rb --- old/yast2-packager-3.1.94/src/lib/packager/product_patterns.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-packager-3.1.97/src/lib/packager/product_patterns.rb 2016-04-25 11:47:26.000000000 +0200 @@ -0,0 +1,145 @@ + +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 SUSE LLC +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of version 2 of the GNU General Public License as published by the +# Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# ------------------------------------------------------------------------------ +# + +require "yast" + +module Yast + # Evaluate the default patterns for the currently selected products + class ProductPatterns + include Yast::Logger + + def initialize + Yast.import "Pkg" + end + + # Find the default patterns for all selected products. + # @note The package management and the products needs to be initialized and + # selected *before* using this method. + # @return [Array<String>] pattern names + def names + @names ||= find + end + + # Select the default patterns to installation + # @note The package management and the products needs to be initialized and + # selected *before* using this method. + # @return [Boolean] true if all patterns were successfuly selected, + # false otherwise + def select + # use map + all? to try installing *all* patterns, plain all? would stop + # at the first failure + names.map { |p| Yast::Pkg.ResolvableInstall(p, :pattern) }.all? + end + + private + + # Find the default patterns for all selected products. + # @return [Array<String>] pattern names + def find + products = Yast::Pkg.ResolvableProperties("", :product, "") + remove_unselected(products) + products.map! { |product| product["name"] } + log.info "Found selected products: #{products}" + + patterns = products.map { |p| product_patterns(p) }.flatten.uniq + log.info "Default patterns for the selected products: #{patterns.inspect}" + + patterns + end + + # Find the default patterns for the product. + # @param [String] product product name + # @return [Array<String>] pattern names + def product_patterns(product) + product_dependencies = dependencies(product) + product_provides = provides(product_dependencies) + + default_patterns(product_provides) + end + + # Find dependencies for the product (it's product package). + # @param [String] product product name + # @return [Array<Hash>] product dependencies, e.g. [{"provides" => "foo"}, + # {"requires" => "bar"}, ...] + def dependencies(product) + product_dependencies = [] + + resolvables = Yast::Pkg.ResolvableProperties(product, :product, "") + remove_unselected(resolvables) + + resolvables.each do |resolvable| + prod_pkg = resolvable["product_package"] + next unless prod_pkg + + release_resolvables = Yast::Pkg.ResolvableDependencies(prod_pkg, :package, "") + remove_unselected(release_resolvables) + + release_resolvables.each do |release_resolvable| + deps = release_resolvable["deps"] + product_dependencies.concat(deps) if deps + end + end + + log.debug "Product #{product} depependencies: #{product_dependencies}" + + product_dependencies + end + # Remove not selected resolvables from the list + # @param [Array<Hash>] resolvables only the Hashes where the key "status" + # maps to :selected value are kept, the rest is removed + def remove_unselected(resolvables) + resolvables.select! { |p| p["status"] == :selected } + end + + # Collect "provides" dependencies from the list. + # @param [Array<Hash>] dependencies all dependencies + # @return [Array<String>] only the "provides" dependencies + # @example + # provides([{"provides" => "foo"}, {"requires" => "bar"}, ...]) => ["foo"] + def provides(dependencies) + provides = [] + + dependencies.each do |dependency| + prov = dependency["provides"] + provides << prov if prov + end + + log.debug "Collected provides dependencies: #{provides.inspect}" + + provides + end + + # Collect default pattern names from the provides list. + # The default pattern is described by the tag "defaultpattern(foo)" + # @param [Array<String>] provides the "provides" dependencies + # @return [Array<String>] the default pattern names, empty if no default + # pattern is found + def default_patterns(provides) + patterns = [] + + provides.each do |provide| + # is it a defaultpattern() provides? + if provide.match(/\Adefaultpattern\((.*)\)\z/) + log.info "Found default pattern provide: #{provide}" + patterns << Regexp.last_match[1].strip + end + end + + log.info "Found default patterns: #{patterns.inspect}" + + patterns + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/src/modules/Packages.rb new/yast2-packager-3.1.97/src/modules/Packages.rb --- old/yast2-packager-3.1.94/src/modules/Packages.rb 2016-04-06 14:52:58.000000000 +0200 +++ new/yast2-packager-3.1.97/src/modules/Packages.rb 2016-04-25 11:47:26.000000000 +0200 @@ -2608,6 +2608,13 @@ (default_patterns | optional_default_patterns).inject(patterns, :<<) end + # preselect the default product patterns (FATE#320199) + # note: must be called *after* selecting the products + require "packager/product_patterns" + product_patterns = ProductPatterns.new + log.info "Found default product patterns: #{product_patterns.names}" + patterns.concat(product_patterns.names) + patterns end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/src/modules/ProductLicense.rb new/yast2-packager-3.1.97/src/modules/ProductLicense.rb --- old/yast2-packager-3.1.94/src/modules/ProductLicense.rb 2016-04-06 14:52:58.000000000 +0200 +++ new/yast2-packager-3.1.97/src/modules/ProductLicense.rb 2016-04-25 11:47:26.000000000 +0200 @@ -1500,24 +1500,23 @@ ) UI.ReplaceWidget(Id(replace_point_ID), rt) - id = Builtins.tostring(src_id) - - # Display info as a popup if exists - if @info_file != nil && - Ops.get(@info_file_already_seen, id, false) != true - if Mode.autoinst - Builtins.y2milestone("Autoinstallation: Skipping info file...") - else - InstShowInfo.show_info_txt(@info_file) - Ops.set(@info_file_already_seen, id, true) - end - end + display_info(src_id) if @info_file && !info_seen?(src_id) CleanUp() true end + # Check if installation info had been seen to given ID + def info_seen?(id) + @info_file_already_seen.fetch(id, false) + end + + # Mark given id as seen + def info_seen!(id) + @info_file_already_seen[id] = true + end + def AskInstalledLicenseAgreement(directory, action) # patterns are hard-coded AskLicenseAgreement( @@ -1610,6 +1609,16 @@ UI.ReplaceWidget(:printing_hint, Label(license_download_label(lic_url))) end end + + # Display info as a popup if exists + def display_info(id) + if Mode.autoinst + Builtins.y2milestone("Autoinstallation: Skipping info file...") + else + InstShowInfo.show_info_txt(@info_file) + info_seen!(id) + end + end end ProductLicense = ProductLicenseClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/test/Makefile.am new/yast2-packager-3.1.97/test/Makefile.am --- old/yast2-packager-3.1.94/test/Makefile.am 2016-04-06 14:52:58.000000000 +0200 +++ new/yast2-packager-3.1.97/test/Makefile.am 2016-04-25 11:47:26.000000000 +0200 @@ -1,5 +1,6 @@ TESTS = \ addon_product_test.rb \ + product_patterns_test.rb \ package_installation_test.rb \ packages_test.rb \ source_dialogs_test.rb \ @@ -8,4 +9,4 @@ TEST_EXTENSIONS = .rb RB_LOG_COMPILER = rspec VERBOSE = 1 -EXTRA_DIST = $(TESTS) +EXTRA_DIST = $(TESTS) product_factory.rb test_helper.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/test/packages_test.rb new/yast2-packager-3.1.97/test/packages_test.rb --- old/yast2-packager-3.1.94/test/packages_test.rb 2016-04-06 14:52:58.000000000 +0200 +++ new/yast2-packager-3.1.97/test/packages_test.rb 2016-04-25 11:47:26.000000000 +0200 @@ -13,6 +13,8 @@ Yast.import "Linuxrc" Yast.import "Pkg" +require "packager/product_patterns" + SCR_STRING_PATH = Yast::Path.new(".target.string") SCR_BASH_PATH = Yast::Path.new(".target.bash") SCR_PROC_CMDLINE_PATH = Yast::Path.new(".proc.cmdline") @@ -253,6 +255,20 @@ expect(logged_errors).to eq 4 end + + it "selects the default product patterns" do + allow(Yast::Packages).to receive(:ComputeSystemPatternList).and_return([]) + allow(Yast::Packages).to receive(:default_patterns).and_return([]) + allow(Yast::Packages).to receive(:optional_default_patterns).and_return([]) + allow(Yast::Pkg).to receive(:ResolvableProperties).and_return([{}]) + + product_patterns = [ "default_pattern_1", "default_pattern_2"] + expect_any_instance_of(Yast::ProductPatterns).to receive(:names).at_least(:once).and_return(product_patterns) + expect(Yast::Pkg).to receive(:ResolvableInstall).with(product_patterns[0], :pattern) + expect(Yast::Pkg).to receive(:ResolvableInstall).with(product_patterns[1], :pattern) + + Yast::Packages.SelectSystemPatterns(false) + end end describe "#log_software_selection" do @@ -390,6 +406,7 @@ context "when fips pattern is available" do before do + allow_any_instance_of(Yast::ProductPatterns).to receive(:names).and_return([]) allow(Yast::Pkg).to receive(:ResolvableProperties). with("fips", :pattern, "").and_return([{ "name" => "fips" }]) end @@ -407,6 +424,7 @@ context "when fips pattern is not available" do before do + allow_any_instance_of(Yast::ProductPatterns).to receive(:names).and_return([]) allow(Yast::Pkg).to receive(:ResolvableProperties). with("fips", :pattern, "").and_return([]) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/test/product_factory.rb new/yast2-packager-3.1.97/test/product_factory.rb --- old/yast2-packager-3.1.94/test/product_factory.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-packager-3.1.97/test/product_factory.rb 2016-04-25 11:47:26.000000000 +0200 @@ -0,0 +1,73 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 SUSE LLC +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of version 2 of the GNU General Public License as published by the +# Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# ------------------------------------------------------------------------------ +# + +# A factory which creates random libzypp products for testing. +class ProductFactory + # Create a product, the default random attributes can be customized via arguments. + # @return [Hash] product hash as returned by the Pkg.ResolvableProperties + # and Pkg.ResolvableDependencies functions + def self.create_product(attrs = {}) + product = {} + + # generate 12 random characters from a-z + charset = ("a".."z").to_a + name = (1..12).map { charset[rand(charset.size)] }.join + + # construct a "human readable" product name + product_name = name.capitalize + # construct the internal product ID + product_id = name[0..4] + # service pack level + sp = rand(4) + 1 + + product["arch"] = attrs["arch"] || "x86_64" + product["category"] = attrs["category"] || "addon" + product["description"] = attrs["description"] || "SUSE Linux Enterprise #{product_name}." + product["display_name"] = attrs["display_name"] || "SUSE Linux Enterprise #{product_name}" + product["download_size"] = attrs["download_size"] || 0 + product["eol"] = attrs["eol"] || 1730332800 + product["flags"] = attrs["flags"] || [] + product["flavor"] = attrs["flavor"] || "POOL" + product["inst_size"] = attrs["inst_size"] || 0 + product["locked"] = attrs.fetch("locked", false) + product["medium_nr"] = attrs["medium_nr"] || 0 + product["name"] = attrs["name"] || "sle-#{product_id}" + product["on_system_by_user"] = attrs.fetch("on_system_by_user", false) + product["product_file"] = attrs["product_file"] || "sle-#{product_id}.prod" + product["product_line"] = attrs["product_line"] || "" + product["product_package"] = attrs.fetch("product_package", "sle-#{product_id}-release") + product["register_release"] = attrs["register_release"] || "" + product["register_target"] = attrs["register_target"] || "sle-12-x86_64" + product["relnotes_url"] = attrs["relnotes_url"] || + "https://www.suse.com/releasenotes/#{product["arch"]}/SLE-#{product_id}/12-SP#{sp}/release-notes-#{product_id}.rpm" + product["relnotes_urls"] = attrs["relnotes_urls"] || [product["relnotes_url"]] + product["short_name"] = attrs["short_name"] || "SLE#{product_id.upcase}12-SP#{sp}" + product["source"] = attrs["source"] || rand(10) + product["status"] = attrs["status"] || :available + product["summary"] = attrs["summary"] || "SUSE Linux Enterprise #{product_name}" + product["transact_by"] = attrs["transact_by"] || :solver + product["type"] = attrs["type"] || "addon" + product["update_urls"] = attrs["update_urls"] || [] + product["vendor"] = attrs["vendor"] || "SUSE LLC https://www.suse.com/" + product["version"] = attrs["version"] || "12.#{sp}-0" + product["version_epoch"] = attrs["version_epoch"] || nil + product["version_release"] = attrs["version_release"] || "0" + product["version_version"] = attrs["version_version"] || "12.#{sp}" + + # add optional dependencies (returned only by ResolvableDependencies) + product["deps"] = attrs["deps"] if attrs.key?("deps") + + product + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-3.1.94/test/product_patterns_test.rb new/yast2-packager-3.1.97/test/product_patterns_test.rb --- old/yast2-packager-3.1.94/test/product_patterns_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-packager-3.1.97/test/product_patterns_test.rb 2016-04-25 11:47:26.000000000 +0200 @@ -0,0 +1,137 @@ +#! /usr/bin/env rspec + +require_relative "test_helper" +require_relative "product_factory" + +require "packager/product_patterns" + +Yast.import "Pkg" + +describe Yast::ProductPatterns do + describe "#names" do + it "returns empty list when there are no products" do + expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") + .and_return([]) + + expect(subject.names).to eq([]) + end + + it "returns empty list when there is no selected product" do + expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") + .and_return([ProductFactory.create_product]) + + expect(subject.names).to eq([]) + end + + it "returns empty list when the product release package is not found" do + product = ProductFactory.create_product("status" => :selected, + "product_package" => nil) + + expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") + .and_return([product]) + expect(Yast::Pkg).to receive(:ResolvableProperties).with(product["name"], :product, "") + .and_return([product]) + + expect(subject.names).to eq([]) + end + + it "returns the default pattern name from the release package" do + default_pattern = "def_pattern" + product_package_name = "product-release" + product_package = { "name" => product_package_name, "status" => :selected, + "deps" => [{ "requires" => "foo" }, { "provides" => "bar" }, + { "provides" => "defaultpattern(#{default_pattern})" }] } + product = ProductFactory.create_product("status" => :selected, + "product_package" => product_package_name) + + expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") + .and_return([product]) + expect(Yast::Pkg).to receive(:ResolvableProperties).with(product["name"], :product, "") + .and_return([product]) + expect(Yast::Pkg).to receive(:ResolvableDependencies).with(product_package_name, :package, "") + .and_return([product_package]) + + expect(subject.names).to eq([default_pattern]) + end + + it "returns the default patterns from all products" do + default_pattern1 = "def_pattern1" + product_package_name1 = "product-release1" + product_package1 = { "name" => product_package_name1, "status" => :selected, + "deps" => [{ "requires" => "foo" }, { "provides" => "bar" }, + { "provides" => "defaultpattern(#{default_pattern1})" }] } + product1 = ProductFactory.create_product("status" => :selected, + "product_package" => product_package_name1) + + default_pattern2 = "def_pattern2" + product_package_name2 = "product-release2" + product_package2 = { "name" => product_package_name2, "status" => :selected, + "deps" => [{ "requires" => "foo" }, { "provides" => "bar" }, + { "provides" => "defaultpattern(#{default_pattern2})" }] } + product2 = ProductFactory.create_product("status" => :selected, + "product_package" => product_package_name2) + + expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") + .and_return([product1, product2]) + expect(Yast::Pkg).to receive(:ResolvableProperties).with(product1["name"], :product, "") + .and_return([product1]) + expect(Yast::Pkg).to receive(:ResolvableProperties).with(product2["name"], :product, "") + .and_return([product2]) + expect(Yast::Pkg).to receive(:ResolvableDependencies).with(product_package_name1, :package, "") + .and_return([product_package1]) + expect(Yast::Pkg).to receive(:ResolvableDependencies).with(product_package_name2, :package, "") + .and_return([product_package2]) + + expect(subject.names.sort).to eq([default_pattern1, default_pattern2].sort) + end + end + + describe "#select" do + context "no default pattern found" do + before do + expect(subject).to receive(:names).and_return([]) + end + + it "does not select anything to install" do + expect(Yast::Pkg).to_not receive(:ResolvableInstall) + + subject.select + end + + it "returns true (success)" do + expect(subject.select).to eq(true) + end + end + + context "default patterns found" do + before do + expect(subject).to receive(:names).and_return(["pattern1", "pattern2"]) + end + + it "selects the default patterns to install" do + expect(Yast::Pkg).to receive(:ResolvableInstall).with("pattern1", :pattern) + expect(Yast::Pkg).to receive(:ResolvableInstall).with("pattern2", :pattern) + + subject.select + end + + it "returns true if all default patterns were selected" do + expect(Yast::Pkg).to receive(:ResolvableInstall).with("pattern1", :pattern) + .and_return(true) + expect(Yast::Pkg).to receive(:ResolvableInstall).with("pattern2", :pattern) + .and_return(true) + + expect(subject.select).to eq(true) + end + + it "returns false if any default pattern could not be selected" do + expect(Yast::Pkg).to receive(:ResolvableInstall).with("pattern1", :pattern) + .and_return(true) + expect(Yast::Pkg).to receive(:ResolvableInstall).with("pattern2", :pattern) + .and_return(false) + + expect(subject.select).to eq(false) + end + end + end +end