Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions service/lib/dinstaller/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Manager

def initialize(config, logger)
@config = config
@probed = false
@logger = logger
@languages = DEFAULT_LANGUAGES
@products = @config.products
Expand All @@ -82,7 +81,7 @@ def select_product(name)

@config.pick_product(name)
@product = name
@probed = false # reset probing when product changed
repositories.delete_all
end

def probe
Expand Down Expand Up @@ -114,7 +113,7 @@ def initialize_target_repos

# Updates the software proposal
def propose
proposal.base_product = @product
proposal.base_product = selected_base_product
proposal.languages = languages
select_resolvables
result = proposal.calculate
Expand Down Expand Up @@ -217,6 +216,10 @@ def installation_repositories
@config.data["software"]["installation_repositories"]
end

def selected_base_product
@config.data["software"]["base_product"]
end

def add_base_repos
installation_repositories.each do |repo|
if repo.is_a?(Hash)
Expand Down
6 changes: 6 additions & 0 deletions service/lib/dinstaller/software/repositories_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def load
end
Yast::Pkg.SourceLoad
end

# Deletes all the repositories
def delete_all
repositories.each(&:delete!)
repositories.clear
end
end
end
end
9 changes: 5 additions & 4 deletions service/test/dinstaller/software/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
let(:repositories) do
instance_double(
DInstaller::Software::RepositoriesManager,
add: nil,
load: nil,
empty?: true
add: nil,
load: nil,
delete_all: nil,
empty?: true
)
end
let(:proposal) do
Expand Down Expand Up @@ -140,7 +141,7 @@

it "creates a new proposal for the selected product" do
expect(proposal).to receive(:languages=).with(["en_US"])
expect(proposal).to receive(:base_product=).with("Tumbleweed")
expect(proposal).to receive(:base_product=).with("openSUSE")
expect(proposal).to receive(:calculate)
subject.propose
end
Expand Down
13 changes: 13 additions & 0 deletions service/test/dinstaller/software/repositories_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@
end
end

describe "#delete_all" do
before do
subject.repositories << repo
subject.repositories << disabled_repo
end

it "deletes all the repositories" do
expect(repo).to receive(:delete!)
expect(disabled_repo).to receive(:delete!)
subject.delete_all
end
end

describe "#enabled" do
before do
subject.repositories << repo
Expand Down