Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests
- Loading branch information
Showing
5 changed files
with
156 additions
and
44 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
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,38 @@ | ||
#! /usr/bin/env rspec | ||
|
||
require_relative "./test_helper" | ||
require_relative "./product_factory" | ||
|
||
require "packager/default_pattern" | ||
|
||
Yast.import "Pkg" | ||
|
||
describe Packager::DefaultPatterns do | ||
describe ".names" do | ||
it "returns empty list when there are no products" do | ||
expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") | ||
.and_return([]) | ||
|
||
expect(subject.names).to eq([]) | ||
end | ||
|
||
it "returns empty list when there is no selected product" do | ||
expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") | ||
.and_return([ProductFactory.create_product]) | ||
|
||
expect(subject.names).to eq([]) | ||
end | ||
|
||
it "returns empty list when the product release package is not found" do | ||
product = ProductFactory.create_product("status" => :selected, | ||
"product_package" => nil) | ||
|
||
expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") | ||
.and_return([product]) | ||
expect(Yast::Pkg).to receive(:ResolvableProperties).with(product["name"], :product, "") | ||
.and_return([product]) | ||
|
||
expect(subject.names).to eq([]) | ||
end | ||
end | ||
end |
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,52 @@ | ||
|
||
class ProductFactory | ||
def self.create_product(attrs = {}) | ||
product = {} | ||
|
||
# generate 12 random characters from a-z | ||
charset = ('a'..'z').to_a | ||
name = (1..12).map{ charset[rand(charset.size)] }.join | ||
|
||
product_name = name.capitalize | ||
product_id = name[0..4] | ||
sp = rand(4) + 1 | ||
|
||
product["arch"] = attrs["arch"] || "x86_64" | ||
product["category"] = attrs["category"] || "addon" | ||
product["description"] = attrs["description"] || "SUSE Linux Enterprise #{product_name}." | ||
product["display_name"] = attrs["display_name"] || "SUSE Linux Enterprise #{product_name}" | ||
product["download_size"] = attrs["download_size"] || 0 | ||
product["eol"] = attrs["eol"] || 1730332800 | ||
product["flags"] = attrs["flags"] || [] | ||
product["flavor"] = attrs["flavor"] || "POOL" | ||
product["inst_size"] = attrs["inst_size"] || 0 | ||
product["locked"] = attrs.fetch("locked", false) | ||
product["medium_nr"] = attrs["medium_nr"] || 0 | ||
product["name"] = attrs["name"] || "sle-#{product_id}" | ||
product["on_system_by_user"] = attrs.fetch("on_system_by_user", false) | ||
product["product_file"] = attrs["product_file"] || "sle-#{product_id}.prod" | ||
product["product_line"] = attrs["product_line"] || "" | ||
product["product_package"] = attrs.fetch("product_package", "sle-#{product_id}-release") | ||
product["register_release"] = attrs["register_release"] || "" | ||
product["register_target"] = attrs["register_target"] || "sle-12-x86_64" | ||
product["relnotes_url"] = attrs["relnotes_url"] || "https://www.suse.com/releasenotes/#{product["arch"]}/SLE-#{product_id}/12-SP#{sp}/release-notes-#{product_id}.rpm" | ||
product["relnotes_urls"] = attrs["relnotes_urls"] || ["https://www.suse.com/releasenotes/#{product["arch"]}/SLE-#{product_id}/12-SP#{sp}/release-notes-#{product_id}.rpm"] | ||
product["short_name"] = attrs["short_name"] || "SLE#{product_id.upcase}12-SP#{sp}" | ||
product["source"] = attrs["source"] || rand(10) | ||
product["status"] = attrs["status"] || :available | ||
product["summary"] = attrs["summary"] || "SUSE Linux Enterprise #{product_name}" | ||
product["transact_by"] = attrs["transact_by"] || :solver | ||
product["type"] = attrs["type"] || "addon" | ||
product["update_urls"] = attrs["update_urls"] || [] | ||
product["vendor"] = attrs["vendor"] || "SUSE LLC <https://www.suse.com/>" | ||
product["version"] = attrs["version"] || "12.#{sp}-0" | ||
product["version_epoch"] = attrs["version_epoch"] || nil | ||
product["version_release"] = attrs["version_release"] || "0" | ||
product["version_version"] = attrs["version_version"] || "12.#{sp}" | ||
|
||
# add optional dependencies (returned only by ResolvableDependencies) | ||
product["deps"] = attrs["deps"] if attrs.has_key?("deps") | ||
|
||
product | ||
end | ||
end |