Skip to content

Commit

Permalink
Merge 80359ae into 9ce5849
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Jan 20, 2022
2 parents 9ce5849 + 80359ae commit b8657ec
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Expand Up @@ -30,6 +30,8 @@ Metrics/AbcSize:
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 350
Exclude:
- test/**/*

# Offense count: 5
# Configuration parameters: CountBlocks.
Expand Down
7 changes: 7 additions & 0 deletions package/yast2-add-on.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jan 20 16:40:26 UTC 2022 - David Diaz <dgonzalez@suse.com>

- Restore the repo unexpanded URL to get it properly saved in
the /etc/zypp/repos.d file (bsc#972046, bsc#1194851).
- 4.4.7

-------------------------------------------------------------------
Thu Jan 20 16:11:51 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

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


Name: yast2-add-on
Version: 4.4.6
Version: 4.4.7
Release: 0
Summary: YaST2 - Add-On media installation code
License: GPL-2.0-only
Expand Down
4 changes: 4 additions & 0 deletions src/lib/add-on/clients/add-on_auto.rb
Expand Up @@ -245,6 +245,10 @@ def create_source(add_on, product, media_url)
adjust_source_attributes(add_on, source_id)
install_product(product)

# Restore the unexpanded URL to have the original URL
# in the saved /etc/zypp/repos.d file (bsc#972046, bsc#1194851).
Pkg.SourceChangeUrl(source_id, media_url)

return :continue
end
end
Expand Down
89 changes: 67 additions & 22 deletions test/y2add_on/clients/add-on_auto_test.rb
Expand Up @@ -313,12 +313,14 @@

context "when there are add-ons products" do
let(:ask_on_error) { true }
let(:unexpanded_url) { "RELURL://product-$releasever.url" }
let(:expanded_url) { "RELURL://product-15.0.url" }
let(:add_on_products) do
[
{
"alias" => "produc_alias",
"ask_on_error" => ask_on_error,
"media_url" => "RELURL://product.url",
"media_url" => unexpanded_url,
"priority" => 20,
"product_dir" => "/"
}
Expand Down Expand Up @@ -349,34 +351,87 @@
end

before do
allow(Yast::AddOnProduct).to receive(:add_on_products).and_return(add_on_products)
allow(Yast::Pkg).to receive(:SourceEditSet)
allow(Yast::Pkg).to receive(:SourceReleaseAll)
allow(Yast::Pkg).to receive(:SourceCreate).and_return(1)
allow(Yast::Pkg).to receive(:SourceEditGet).and_return(repos)
allow(Yast::Pkg).to receive(:ExpandedUrl)
# To test indirectly the "preferred_name_for" method
# For testing #preferred_name_for" indirectly
allow(Yast::Pkg).to receive(:RepositoryScan)
.with(anything)
.and_return([["Updated repo", "/"]])

allow(Yast::AddOnProduct).to receive(:add_on_products).and_return(add_on_products)

# For testing regresion with $releasever (bsc#1194851)
allow(Yast::AddOnProduct).to receive(:SetRepoUrlAlias).and_return(expanded_url)
end

it "stores repos according to information given" do
expect(Yast::Pkg).to receive(:SourceEditSet).with(repos_to_store)

client.write
end

it "releases the media accessors" do
expect(Yast::Pkg).to receive(:SourceReleaseAll)

client.write
end

# For testing regresion with $releasever (bsc#1194851)
it "restores the unexpanded URL" do
expect(Yast::Pkg).to receive(:SourceChangeUrl).with(1, unexpanded_url)

client.write
end

context "and product creation fails" do
before do
allow(Yast::Report).to receive(:Error)
allow(Yast::Pkg).to receive(:SourceCreate).and_return(-1)
allow(Yast::Popup).to receive(:ContinueCancel).and_return(retry_on_error, false)
end

let(:retry_on_error) { true }

context "ask_on_error=true" do
let(:ask_on_error) { true }
it "ask the user to make it available" do
expect(Yast::Popup).to receive(:ContinueCancel)

it "ask to make it available" do
expect(Yast::Popup).to receive(:ContinueCancel).and_return false
client.write
end

# We are returning false on the ContinueCancel mock, so we decide to
# stop retrying and the error is finally displayed
allow(Yast::Report).to receive(:Error)
context "and user wants to retry" do
let(:retry_on_error) { true }

client.write
it "tries it again" do
expect(Yast::Pkg).to receive(:SourceCreate).with(expanded_url, "/").twice

client.write
end

it "does not reports an error while retrying" do
expect(Yast::Report).to receive(:Error).exactly(1).times

client.write
end
end

context "and user decides not retrying" do
let(:retry_on_error) { false }

it "does not try it again" do
expect(Yast::Pkg).to receive(:SourceCreate).once

client.write
end

it "reports an error" do
expect(Yast::Report).to receive(:Error)

client.write
end
end
end

Expand All @@ -385,6 +440,8 @@

it "does not ask to make it available" do
expect(Yast::Popup).to_not receive(:ContinueCancel)

client.write
end

it "reports the error" do
Expand All @@ -394,18 +451,6 @@
end
end
end

it "stores repos according to information given" do
expect(Yast::Pkg).to receive(:SourceEditSet).with(repos_to_store)

client.write
end

it "releases the media accessors" do
expect(Yast::Pkg).to receive(:SourceReleaseAll)

client.write
end
end
end

Expand Down

0 comments on commit b8657ec

Please sign in to comment.