Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Dec 5, 2023
1 parent 7a19b73 commit 81a5ed6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
4 changes: 2 additions & 2 deletions service/lib/agama/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ def patterns(filtered)
patterns = patterns.select(&:user_visible) if filtered

# only display the configured patterns
if product.user_patterns
patterns.select! {|p| product.user_patterns.include?(p.name)}
if product.user_patterns && filtered
patterns.select! { |p| product.user_patterns.include?(p.name) }
end

patterns
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/software/product_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def product_data_from_config(id)
optional_patterns: config.arch_elements_from(
id, "software", "optional_patterns", property: :pattern
),
user_patterns: config.arch_elements_from(
user_patterns: config.arch_elements_from(
id, "software", "user_patterns", property: :pattern, default: nil
)
}
Expand Down
54 changes: 54 additions & 0 deletions service/test/agama/software/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,60 @@
end
end

describe "#patterns" do
it "returns only the specified patterns" do
expect(Y2Packager::Resolvable).to receive(:find).and_return(
double(
arch: "x86_64",
category: "Base Technologies",
description: "YaST tools for installing your system.",
icon: "./yast",
kind: :pattern,
name: "yast2_install_wf",
order: "1240",
source: 0,
summary: "YaST Installation Packages",
user_visible: false,
version: "20220411-1.4"
),
double(
arch: "x86_64",
category: "Base Technologies",
description: "YaST tools for basic system administration.",
icon: "./yast",
kind: :pattern,
name: "yast2_basis",
order: "1220",
source: 0,
summary: "YaST Base Utilities",
user_visible: true,
version: "20220411-1.4"
),
double(
arch: "noarch",
category: "Graphical Environments",
description:
"Packages providing the Plasma desktop environment and applications from KDE.",
icon: "./pattern-kde",
kind: :pattern,
name: "kde",
order: "1110",
source: 0,
summary: "KDE Applications and Plasma 5 Desktop",
user_visible: true,
version: "20230801-1.1"
)
)

expect(config).to receive(:user_patterns).and_return(["kde"])
patterns = subject.patterns(true)

expect(patterns).to contain_exactly(
an_object_having_attributes(name: "kde")
)
end
end

describe "#propose" do
before do
subject.select_product("Tumbleweed")
Expand Down

0 comments on commit 81a5ed6

Please sign in to comment.