Skip to content

Commit

Permalink
self-update: do not show errors when using the default repos
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Feb 14, 2017
1 parent 75c903f commit a84fcd2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/lib/installation/clients/inst_update_installer.rb
Expand Up @@ -230,11 +230,14 @@ def add_repository(repo)
false

rescue ::Installation::UpdatesManager::CouldNotFetchUpdateFromRepo
if repo.user_defined?
# TRANSLATORS: %s is an URL
Report.Error(format(_("Could not fetch update from\n%s.\n\n"), repo.uri))
Report.Error(format(_("Could not fetch update from\n%s.\n\n"), repo.uri))
end
false

rescue ::Installation::UpdatesManager::CouldNotProbeRepo
return false unless repo.user_defined?
msg = could_not_probe_repo_msg(repo.uri)
if Mode.auto
Report.Warning(msg)
Expand Down
36 changes: 28 additions & 8 deletions test/inst_update_installer_test.rb
Expand Up @@ -19,18 +19,18 @@
let(:url) { "http://update.opensuse.org/\$arch/update.dud" }
let(:real_url) { "http://update.opensuse.org/#{arch}/update.dud" }
let(:remote_url) { true }
let(:user_defined) { true }
let(:update) { double("update", uri: URI(real_url), remote?: remote_url, user_defined?: user_defined) }
let(:updates) { [update] }
let(:arch) { "x86_64" }
let(:all_signed?) { true }
let(:network_running) { true }
let(:repo) { double("repo") }
let(:has_repos) { true }
let(:restarting) { false }
let(:profile) { {} }
let(:ay_profile) { double("Yast::Profile", current: profile) }
let(:ay_profile_location) { double("Yast::ProfileLocation") }
let(:finder) { ::Installation::UpdateRepositoriesFinder.new }
let(:update) { double("update", uri: URI(real_url), remote?: remote_url) }
let(:updates) { [update] }

before do
allow(::Installation::UpdateRepositoriesFinder).to receive(:new).and_return(finder)
Expand Down Expand Up @@ -107,9 +107,7 @@
end

context "when some update is available" do
before do
allow(Yast::ProductFeatures).to receive(:GetStringFeature).and_return(url)
end
let(:updates) { [update] }

context "and update works" do
before do
Expand All @@ -134,7 +132,7 @@
end
end

context "when the update cannot be fetched" do
context "when the update cannot be fetched from a user defined repository" do
it "shows an error and returns :next" do
expect(Yast::Popup).to receive(:Error)
expect(manager).to receive(:add_repository)
Expand All @@ -143,6 +141,17 @@
end
end

context "when the update cannot be fetched from a default repository" do
let(:user_defined) { false }

it "does not show any error and returns :next" do
expect(Yast::Popup).to_not receive(:Error)
expect(manager).to receive(:add_repository)
.and_raise(::Installation::UpdatesManager::CouldNotFetchUpdateFromRepo)
expect(subject.main).to eq(:next)
end
end

context "when repository is empty" do
let(:has_repos) { false }

Expand All @@ -153,7 +162,18 @@
end
end

context "when repository can't be probed" do
context "when a default repository can't be probed" do
let(:user_defined) { false }

it "does not show any error and returns :next" do
expect(Yast::Popup).to_not receive(:YesNo)
expect(manager).to receive(:add_repository)
.and_raise(::Installation::UpdatesManager::CouldNotProbeRepo)
expect(subject.main).to eq(:next)
end
end

context "when a user defined repository can't be probed" do
before do
allow(manager).to receive(:add_repository)
.and_raise(::Installation::UpdatesManager::CouldNotProbeRepo)
Expand Down

0 comments on commit a84fcd2

Please sign in to comment.