Skip to content

Commit

Permalink
Improve the test
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jan 16, 2019
1 parent 3042bc9 commit 47c3169
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/lib/registration/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def update_system(target_distro = nil)
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
Expand Down
44 changes: 25 additions & 19 deletions test/registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,35 +118,41 @@
end

describe "#get_addon_list" do
let(:base_product) do
{
"name" => "SLES",
"version" => "12",
"arch" => "x86_64",
"release_type" => "DVD"
}
end
before do
remote_product = load_yaml_fixture("remote_product.yml")
allow(SUSE::Connect::YaST).to receive(:show_product).and_return(remote_product)
# no product renames defined
allow(Registration::SwMgmt).to receive(:update_product_renames).with({})
allow(Registration::SwMgmt).to receive(:base_product_to_register).and_return(base_product)
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([])
context "no base product found" do
let(:base_product) { nil }

it "returns empty list if no base product is found" do
expect(Registration::Registration.new.get_addon_list).to eq([])
end
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
context "a base product is found" do
let(:base_product) do
{
"name" => "SLES",
"version" => "12",
"arch" => "x86_64",
"release_type" => "DVD"
}
end

it "downloads available extensions" do
addons = Registration::Registration.new.get_addon_list

# HA-GEO is extension for HA so it's not included in the list
# also the base product must not be included in the list
expect(addons.map(&:identifier)).to include("sle-we", "sle-sdk",
"sle-module-legacy", "sle-module-web-scripting", "sle-module-public-cloud",
"sle-module-adv-systems-management", "sle-hae")
# HA-GEO is extension for HA so it's not included in the list
# also the base product must not be included in the list
expect(addons.map(&:identifier)).to include("sle-we", "sle-sdk",
"sle-module-legacy", "sle-module-web-scripting", "sle-module-public-cloud",
"sle-module-adv-systems-management", "sle-hae")
end
end
end

Expand Down

0 comments on commit 47c3169

Please sign in to comment.