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 fd9b758
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion service/lib/agama/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def patterns(filtered)
patterns = patterns.select(&:user_visible) if filtered

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

Expand Down
57 changes: 57 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,63 @@
end
end

describe "#patterns" do
it "returns only the specified patterns" do
expect(Y2Packager::Resolvable).to receive(:find).and_return(
instance_double(
Y2Packager::Resolvable,
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"
),
instance_double(
Y2Packager::Resolvable,
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"
),
instance_double(
Y2Packager::Resolvable,
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 fd9b758

Please sign in to comment.