Skip to content
Permalink
Browse files

adapted testcases

  • Loading branch information...
schubi2 committed Feb 1, 2018
1 parent b63ef2c commit fb90d75e5303ecb62ae480131945945e3dbe3866
Showing with 31 additions and 12 deletions.
  1. +4 −4 src/modules/AutoinstSoftware.rb
  2. +22 −8 test/AutoinstSoftware_test.rb
  3. +5 −0 test/fixtures/profiles/software.xml
@@ -1093,12 +1093,12 @@ def SelectPackagesForInstallation
# Blaming only packages which have been selected by the AutoYaST configuration file
log.error "Cannot select following packages for installation:" unless failed_packages.empty?
failed_packages.reject! do |name,reason|
if @Software["packages"] && !@Software["packages"].include?(name)
log.error(" #{name} : #{reason} (selected by YAST automatically)")
true
else
if @Software["packages"] && @Software["packages"].include?(name)
log.error(" #{name} : #{reason} (selected by AutoYaST configuration file)")
false
else
log.error(" #{name} : #{reason} (selected by YAST automatically)")
true
end
end

@@ -30,24 +30,38 @@
end

describe "selecting packages for installation" do
it "shows a popup if some packages have not been found" do

before(:each) do
allow(subject).to receive(:autoinstPackages).and_return(["a1"])
expect(Yast::Packages).to receive(:ComputeSystemPackageList).and_return([])
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3"])
allow(subject).to receive(:autoinstPackages).and_return(["a1"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a1"]).and_return({"a1" => "not found"})
end

it "shows a popup if some packages have not been found" do
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3"]).and_return({})
expect(Yast::Report).to receive(:Error)
subject.SelectPackagesForInstallation()
end

it "shows a popup for not founded packages which have been selected by AY configuration only" do
allow(subject).to receive(:autoinstPackages).and_return(["a1"])
expect(Yast::Packages).to receive(:ComputeSystemPackageList).and_return([])
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a1"]).and_return({"a1" => "not found"})
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3"]).and_return({"a2" => "not found"})
expect(Yast::Report).to receive(:Error)
subject.Import(Yast::Profile.current["software"])
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3","a4"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3","a4"]).and_return({"a4" => "not found"})
# a4 is not in the software/packages section
expect(Yast::Report).to receive(:Error).with("These packages cannot be found in the software repositories:\na1: not found\n")
subject.SelectPackagesForInstallation()
end

it "shows no popup if no software section has been defined in the AY configuration" do
subject.Import({})
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3","a4"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3","a4"]).and_return({"a4" => "not found"})
expect(Yast::Report).to_not receive(:Error)
subject.SelectPackagesForInstallation()
end

end

end
@@ -9,5 +9,10 @@
<post-package>a2</post-package>
<post-package>a3</post-package>
</post-packages>
<packages config:type="list">
<post-package>a1</post-package>
<post-package>a2</post-package>
<post-package>a3</post-package>
</packages>
</software>
</profile>

0 comments on commit fb90d75

Please sign in to comment.
You can’t perform that action at this time.