Skip to content

Commit

Permalink
Add none? method to Resolvable class
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jan 7, 2022
1 parent 8c6f0fe commit 18e37c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/packages/src/lib/y2packager/resolvable.rb
Expand Up @@ -81,6 +81,15 @@ def self.any?(params)
Yast::Pkg.AnyResolvable(params)
end

# Return true when there is no resolvable matching the requested parameters or false
# otherwise.
#
# @param params [Hash<Symbol,Object>] The requested attributes
# @return [Boolean] `true` if no matching resolvable is found, `false` otherwise.
def self.none?(params)
!any?(params)
end

#
# Constructor, initialize the object from a pkg-bindings resolvable hash.
#
Expand Down
19 changes: 19 additions & 0 deletions library/packages/test/y2packager/resolvable_test.rb
Expand Up @@ -141,6 +141,25 @@ def accept_unsigned_file(file, _repo)
end
end

describe ".none?" do
it "returns true if no package is found" do
expect(Y2Packager::Resolvable.none?(kind: :package, name: "not existing")).to be true
end

it "returns true if no product is found" do
expect(Y2Packager::Resolvable.none?(kind: :product, name: "openSUSE")).to be true
end

it "returns false if a package with name is found" do
# use some noarch package here, the testing data covers only the x86_64 arch
expect(Y2Packager::Resolvable.none?(kind: :package, name: "yast2-add-on")).to be false
end

it "returns false if a package is found" do
expect(Y2Packager::Resolvable.none?(kind: :package)).to be false
end
end

describe "#vendor" do
it "lazy loads the missing attributes" do
# use some noarch package here, the testing data covers only the x86_64 arch
Expand Down

0 comments on commit 18e37c2

Please sign in to comment.