Skip to content

Commit

Permalink
use "predecessor" attribute to handle addon renames (bnc#883206)
Browse files Browse the repository at this point in the history
- 3.1.84
  • Loading branch information
lslezak committed Jul 4, 2014
1 parent 4fc8792 commit 4ae4065
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
7 changes: 7 additions & 0 deletions package/yast2-registration.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jul 4 07:55:33 UTC 2014 - lslezak@suse.cz

- use "predecessor" attribute to handle addons/extensions renames
(bnc#883206)
- 3.1.84

-------------------------------------------------------------------
Thu Jul 3 13:03:49 UTC 2014 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 3.1.83
Version: 3.1.84
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
6 changes: 5 additions & 1 deletion src/lib/registration/addon.rb
Expand Up @@ -77,6 +77,7 @@ def create_addon_with_deps(root)
:friendly_name,
:identifier,
:name,
:predecessor,
:release_type,
:version

Expand Down Expand Up @@ -135,8 +136,11 @@ def available?
@pure_addon.available != false
end

# Checks whether this addon updates an old addon
# @param [Hash] old_addon addon Hash received from pkg-bindings
# @return [Boolean] true if it updates the old addon, false otherwise
def updates_addon?(old_addon)
old_addon["name"] == identifier
old_addon["name"] == identifier || old_addon["name"] == predecessor
end

end
Expand Down
30 changes: 30 additions & 0 deletions test/addon_spec.rb
Expand Up @@ -196,7 +196,37 @@
it "returns true when the addon availability is not set" do
expect(addon.selectable?).to be_true
end
end

describe "#updates_addon?" do
it "returns true if the old addon has the same name" do
product = addon_generator("zypper_name" => "sle-sdk")

new_addon = Registration::Addon.new(product)
old_addon = { "name" => "sle-sdk", "version" => "12", "arch" => "x86_64" }

expect(new_addon.updates_addon?(old_addon)).to be_true
end

it "returns true if the old addon is a predecessor" do
# "sle-haegeo" (SLE11-SP2) has been renamed to "sle-ha-geo" (SLE12)
product = addon_generator("zypper_name" => "sle-ha-geo",
"predecessor" => "sle-haegeo")

new_addon = Registration::Addon.new(product)
old_addon = { "name" => "sle-haegeo", "version" => "12", "arch" => "x86_64" }

expect(new_addon.updates_addon?(old_addon)).to be_true
end

it "returns false if the old addon is different" do
product = addon_generator("zypper_name" => "sle-sdk")

new_addon = Registration::Addon.new(product)
old_addon = { "name" => "sle-hae", "version" => "12", "arch" => "x86_64" }

expect(new_addon.updates_addon?(old_addon)).to be_false
end
end

end
1 change: 1 addition & 0 deletions test/factories.rb
Expand Up @@ -14,6 +14,7 @@ def suse_connect_product_generator(attrs={})
params['free'] = attrs.fetch('free', true)
params['eula_url'] = attrs['eula_url']
params["extensions"] = attrs['extensions'] || []
params["predecessor"] = attrs["predecessor"]

params
end
Expand Down

0 comments on commit 4ae4065

Please sign in to comment.