Skip to content

Commit

Permalink
Merge pull request #388 from yast/merge_sp3_fix
Browse files Browse the repository at this point in the history
Merge the SP3 test fix to SP4
  • Loading branch information
lslezak committed Jul 25, 2018
2 parents 996bbc7 + 4c9f506 commit db31ce0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 7 deletions.
13 changes: 13 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
-------------------------------------------------------------------
Wed Jul 25 11:58:13 UTC 2018 - lslezak@suse.com

- Updated the unit test to pass with the latest SUSEConnect
(bsc#1102540)
- 3.2.14

-------------------------------------------------------------------
Wed Jul 18 10:45:15 CEST 2018 - schubi@suse.de

- Do not crash if getting zypp lock failed. (bnc#1043125)
- 3.2.13

-------------------------------------------------------------------
Thu Jun 22 13:46:00 UTC 2017 - lslezak@suse.cz

Expand Down
4 changes: 2 additions & 2 deletions package/yast2-registration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 3.2.12
Version: 3.2.14
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down Expand Up @@ -53,7 +53,7 @@ BuildRequires: update-desktop-files
BuildRequires: yast2-devtools >= 3.1.39
BuildRequires: rubygem(yast-rake) >= 0.2.5
BuildRequires: rubygem(rspec)
BuildRequires: rubygem(suse-connect) >= 0.2.22
BuildRequires: rubygem(suse-connect) >= 0.3.11
BuildRequires: yast2-slp >= 3.1.9
# packager/product_patterns.rb
BuildRequires: yast2-packager >= 3.1.95
Expand Down
6 changes: 6 additions & 0 deletions src/clients/scc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def main
return WFM.call("inst_scc", WFM.Args)
rescue Registration::SourceRestoreError => e
retry if fix_repositories(e.message)
rescue Registration::PkgAborted => e
# Libzypp init has failed because another application
# has already locked the zypp stack. The user has already
# decided to exit the module. So nothing more has to be
# done here.
log.info "User abort..."
ensure
Wizard.CloseDialog
end
Expand Down
5 changes: 5 additions & 0 deletions src/lib/registration/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ class SourceRestoreError < PkgError
# generic download error
class DownloadError < RuntimeError
end

# User decision to abort because libzypp has already been
# locked by another application.
class PkgAborted < RuntimeError
end
end
3 changes: 3 additions & 0 deletions src/lib/registration/sw_mgmt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class SwMgmt
def self.init(load_packages = false)
# false = do not allow continuing without the libzypp lock
lock = PackageLock.Connect(false)
# User would like to abort
raise_pkg_exception(PkgAborted) if lock["aborted"]
# locking has failed
raise_pkg_exception unless lock["connected"]

# display progress when refreshing repositories
Expand Down
2 changes: 1 addition & 1 deletion test/connect_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "registration/connect_helpers"

# helper for creating the SCC API error exceptions
def api_error(code: 400, headers: {}, body: "")
def api_error(code: 400, headers: {}, body: {})
SUSE::Connect::ApiError.new(
OpenStruct.new(
code: code,
Expand Down
22 changes: 18 additions & 4 deletions test/sw_mgmt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@

describe ".init" do
before do
allow(Yast::PackageLock).to receive(:Connect).and_return("connected" => connected)
allow(Yast::PackageLock).to receive(:Connect).and_return("connected" => connected,
"aborted" => aborted)
end

context "when the libzypp lock can be obtained" do
let(:connected) { true }
let(:aborted) { false }

before do
expect(Yast::PackageCallbacks).to receive(:InitPackageCallbacks)
Expand All @@ -76,10 +78,22 @@
end

context "when the libzypp lock cannot be obtained" do
let(:connected) { false }
context "when user has NOT aborted" do
let(:connected) { false }
let(:aborted) { false }

it "raises an PkgError exception" do
expect { subject.init }.to raise_error(Registration::PkgError)
it "raises an PkgError exception" do
expect { subject.init }.to raise_error(Registration::PkgError)
end
end

context "when user has aborted" do
let(:connected) { false }
let(:aborted) { true }

it "raises an PkgAborted exception" do
expect { subject.init }.to raise_error(Registration::PkgAborted)
end
end
end
end
Expand Down

0 comments on commit db31ce0

Please sign in to comment.