Skip to content

Commit

Permalink
updated testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Oct 1, 2020
1 parent eaf5d4a commit b49c564
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 15 deletions.
72 changes: 72 additions & 0 deletions test/data/zypp/opensuse_sles.yml
@@ -0,0 +1,72 @@
- arch: x86_64
kind: :product
category: base
description: openSUSE is a distribution by the openSUSE.org project.
display_name: openSUSE (INSTALLED)
download_size: 0
flags: []
flavor: dvd-promo
inst_size: 0
locked: false
medium_nr: 0
name: openSUSE
product_file: /etc/products.d/openSUSE.prod
register_release: ''
register_target: openSUSE-15.1-x86_64
relnotes_url: http://doc.opensuse.org/release-notes/x86_64/openSUSE/15.1/release-notes-openSUSE.rpm
relnotes_urls:
- http://doc.opensuse.org/release-notes/x86_64/openSUSE/15.1/release-notes-openSUSE.rpm
short_name: openSUSE
source: -1
status: :installed
summary: openSUSE 15.1
transact_by: :solver
type: base
update_urls: []
upgrades: []
vendor: openSUSE
version: 15.1-1.10
- arch: x86_64
category: base
description: |-
SUSE Linux Enterprise offers a comprehensive
suite of products built on a single code base.
The platform addresses business needs from
the smallest thin-client devices to the world's
most powerful high-performance computing
and mainframe servers. SUSE Linux Enterprise
offers common management tools and technology
certifications across the platform, and
each product is enterprise-class.
display_name: SUSE Linux Enterprise Server 12 SP3
download_size: 0
eol: 1730332800
flags: []
flavor: DVD
inst_size: 0
locked: false
medium_nr: 0
name: SLES
on_system_by_user: true
product_file: "/mnt/etc/products.d/SLES.prod"
product_line: sles
register_flavor: ''
register_release: ''
register_target: sle-15-x86_64
relnotes_url: https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15-SP2/release-notes-sles.rpm
relnotes_urls:
- https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15-SP2/release-notes-sles.rpm
short_name: SLES15-SP2
source: -1
status: :removed
summary: SUSE Linux Enterprise Server 15 SP2
transact_by: :solver
type: base
update_urls: []
upgrades: []
vendor: SUSE
version: 15.2-0
version_epoch:
version_release: '0'
version_version: '15.2'

65 changes: 50 additions & 15 deletions test/update_test.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env rspec

require_relative "test_helper"
require "y2packager/product"

Yast.import "Update"
Yast.import "Installation"
Expand Down Expand Up @@ -386,35 +387,69 @@ def default_SetDesktopPattern_stubs
end

describe "#InitUpdate" do
context "no compatile vendors are defined in the control file" do
context "installation mode" do
before do
allow(Yast::ProductFeatures).to receive(:GetFeature)
.with("software", "compatible_vendors")
.and_return(nil)
allow(Yast::ProductFeatures).to receive(:GetFeature)
.with("software", "silently_downgrade_packages")
.and_return(true)
allow(Yast::Mode).to receive(:update).and_return(false)
end

it "does nothing" do
it "do not set compatible vendors at all" do
expect(Yast::Pkg).to_not receive(:SetAdditionalVendors)
Yast::Update.InitUpdate()
end
end

context "compatilbe vendors are defined in the control file" do
context "upgrade mode" do
before do
allow(Yast::ProductFeatures).to receive(:GetFeature)
.with("software", "compatible_vendors")
.and_return(["openSUSE", "SLES"])
allow(Yast::Mode).to receive(:update).and_return(true)
allow(Yast::ProductFeatures).to receive(:GetFeature)
.with("software", "silently_downgrade_packages")
.and_return(true)
allow(Y2Packager::Resolvable).to receive(:find).with(kind: :product)
.and_return(all_products)
end

it "set it in the solver" do
expect(Yast::Pkg).to receive(:SetAdditionalVendors).with(kind_of(Array))
Yast::Update.InitUpdate()
# context "no product change SLES->SLES" do
# end

context "product change openSUSE->SLES" do
before do
let(:all_products_hash) do
YAML.load_file(File.join(__dir__,
"../data/zypp/opensuse_sles.yml"))
end

let(:all_products) do
all_products_hash.map { |p| Y2Packager::Resolvable.new(p) }
end
allow(Yast::Installation).to receive(:installedVersion)
.and_return("nameandversion" => "openSUSE 15.1")
end

context "no compatile vendors are defined in the control file" do
before do
allow(Yast::ProductFeatures).to receive(:GetFeature)
.with("software", "upgrade")
.and_return({})
end

it "do not set compatible vendors at all" do
expect(Yast::Pkg).to_not receive(:SetAdditionalVendors)
Yast::Update.InitUpdate()
end
end

context "compatilbe vendors are defined in the control file" do
before do
allow(Yast::ProductFeatures).to receive(:GetFeature)
.with("software", "upgrade")
.and_return("compatible_vendors" =>["openSUSE", "SLES"])
end

it "set it in the solver" do
expect(Yast::Pkg).to receive(:SetAdditionalVendors).with(kind_of(Array))
Yast::Update.InitUpdate()
end
end
end
end
end
Expand Down

0 comments on commit b49c564

Please sign in to comment.