Skip to content

Commit

Permalink
Extend filter_release and filter_version tests
Browse files Browse the repository at this point in the history
Now the tests use also LT, LTE, GT, and GTE comparisons.
  • Loading branch information
m-blaha authored and j-mracek committed Jan 16, 2024
1 parent 50277b6 commit d745092
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/libdnf5/rpm/test_package_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,29 @@ void RpmPackageQueryTest::test_filter_version() {

expected = {get_pkg("pkg-libs-1:1.3-4.x86_64")};
CPPUNIT_ASSERT_EQUAL(expected, to_vector(query2));

// packages with version < "1.3"
PackageQuery query3(base);
query3.filter_version({"1.3"}, libdnf5::sack::QueryCmp::LT);

expected = {
get_pkg("pkg-0:1.2-3.src"),
get_pkg("pkg-0:1.2-3.x86_64"),
get_pkg("pkg-libs-0:1.2-3.x86_64"),
get_pkg("pkg-libs-1:1.2-4.x86_64")};
CPPUNIT_ASSERT_EQUAL(expected, to_vector(query3));

// packages with version <= "1.3"
PackageQuery query4(base);
query4.filter_version({"1.3"}, libdnf5::sack::QueryCmp::LTE);

expected = {
get_pkg("pkg-0:1.2-3.src"),
get_pkg("pkg-0:1.2-3.x86_64"),
get_pkg("pkg-libs-0:1.2-3.x86_64"),
get_pkg("pkg-libs-1:1.2-4.x86_64"),
get_pkg("pkg-libs-1:1.3-4.x86_64")};
CPPUNIT_ASSERT_EQUAL(expected, to_vector(query4));
}


Expand All @@ -523,6 +546,25 @@ void RpmPackageQueryTest::test_filter_release() {

expected = {get_pkg("pkg-libs-1:1.2-4.x86_64"), get_pkg("pkg-libs-1:1.3-4.x86_64")};
CPPUNIT_ASSERT_EQUAL(expected, to_vector(query2));

// packages with release > "3"
PackageQuery query3(base);
query3.filter_release({"3"}, libdnf5::sack::QueryCmp::GT);

expected = {get_pkg("pkg-libs-1:1.2-4.x86_64"), get_pkg("pkg-libs-1:1.3-4.x86_64")};
CPPUNIT_ASSERT_EQUAL(expected, to_vector(query3));

// packages with release >= "3"
PackageQuery query4(base);
query4.filter_release({"3"}, libdnf5::sack::QueryCmp::GTE);

expected = {
get_pkg("pkg-0:1.2-3.src"),
get_pkg("pkg-0:1.2-3.x86_64"),
get_pkg("pkg-libs-0:1.2-3.x86_64"),
get_pkg("pkg-libs-1:1.2-4.x86_64"),
get_pkg("pkg-libs-1:1.3-4.x86_64")};
CPPUNIT_ASSERT_EQUAL(expected, to_vector(query4));
}

void RpmPackageQueryTest::test_filter_priority() {
Expand Down

0 comments on commit d745092

Please sign in to comment.