Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jan 16, 2019
1 parent a269c9d commit 3042bc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/lib/registration/registration.rb
Expand Up @@ -130,13 +130,15 @@ def update_system(target_distro = nil)
ret
end

# Get the list of addons
# @return [Array<Addon>] List of addons, empty if no base product is found
def get_addon_list
# extensions for base product
base_product = ::Registration::SwMgmt.base_product_to_register

if !base_product
log.warn "No base product, skipping addons"
return
return []
end

log.info "Reading available addons for product: #{base_product["name"]}"
Expand Down
16 changes: 10 additions & 6 deletions test/registration_spec.rb
Expand Up @@ -127,15 +127,19 @@
}
end
before do
expect(Registration::SwMgmt).to receive(:base_product_to_register).and_return(base_product)
end

it "downloads available extensions" do
remote_product = load_yaml_fixture("remote_product.yml")
expect(SUSE::Connect::YaST).to receive(:show_product).and_return(remote_product)
allow(SUSE::Connect::YaST).to receive(:show_product).and_return(remote_product)
# no product renames defined
expect(Registration::SwMgmt).to receive(:update_product_renames).with({})
allow(Registration::SwMgmt).to receive(:update_product_renames).with({})
end

it "returns empty list if no base product is found" do
expect(Registration::SwMgmt).to receive(:base_product_to_register).and_return(nil)
expect(Registration::Registration.new.get_addon_list).to eq([])
end

it "downloads available extensions" do
expect(Registration::SwMgmt).to receive(:base_product_to_register).and_return(base_product)
addons = Registration::Registration.new.get_addon_list

# HA-GEO is extension for HA so it's not included in the list
Expand Down

0 comments on commit 3042bc9

Please sign in to comment.