Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#! /usr/bin/env rspec | ||
|
||
require_relative "spec_helper" | ||
require "yaml" | ||
|
||
describe Registration::AutoyastAddons do | ||
let(:registration) { double("registration") } | ||
let(:unsorted_addons) { [ | ||
# deliberately in a wrong registration order | ||
{"name" => "sle-module-desktop-applications", "version" => "15", "arch" => "x86_64"}, | ||
{"name" => "sle-module-basesystem", "version" => "15", "arch" => "x86_64"} | ||
] } | ||
|
||
# depends on the "sle-module-basesystem" which is not listed here | ||
let(:incomplete_addons) { ["name" => "sle-module-desktop-applications", "version" => "15", "arch" => "x86_64"] } | ||
|
||
# the expected addons to register in the correct order | ||
let(:expected_registration_order) { ["sle-module-basesystem", "sle-module-desktop-applications"] } | ||
|
||
before do | ||
addons = load_yaml_fixture("sle15_addons.yaml") | ||
allow(Registration::Addon).to receive(:find_all).and_return(addons) | ||
allow(registration).to receive(:get_addon_list).and_return(addons) | ||
end | ||
|
||
after do | ||
Registration::Addon.reset! | ||
end | ||
|
||
describe "#select" do | ||
it "sorts the addons according to their dependencies" do | ||
ayaddons = Registration::AutoyastAddons.new(unsorted_addons, registration) | ||
ayaddons.select | ||
|
||
expect(ayaddons.selected_addons.map(&:identifier)).to eq(expected_registration_order) | ||
end | ||
|
||
it "automatically selects the dependent addons" do | ||
ayaddons = Registration::AutoyastAddons.new(incomplete_addons, registration) | ||
ayaddons.select | ||
|
||
expect(ayaddons.selected_addons.map(&:identifier)).to eq(expected_registration_order) | ||
end | ||
end | ||
|
||
describe "#register" do | ||
it "registers the selected addons" do | ||
expect(registration).to receive(:register_product).with({"name"=>"sle-module-basesystem", "reg_code"=>nil, "arch"=>"x86_64", "version"=>"15"}).ordered | ||
expect(registration).to receive(:register_product).with({"name"=>"sle-module-desktop-applications", "reg_code"=>nil, "arch"=>"x86_64", "version"=>"15"}).ordered | ||
|
||
ayaddons = Registration::AutoyastAddons.new(unsorted_addons, registration) | ||
ayaddons.select | ||
ayaddons.register | ||
|
||
# expect(ayaddons.selected_addons.map(&:identifier)).to eq(expected_registration_order) | ||
end | ||
|
||
xit "registers the selected addon using the provided reg. key" do | ||
|
||
end | ||
end | ||
|
||
end |