richardphibel / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone
2e24b4
From a61b0105aafeea8487902463f789e6ed00021eb3 Mon Sep 17 00:00:00 2001
2e24b4
From: Jaroslav Mracek <jmracek@redhat.com>
2e24b4
Date: Wed, 5 May 2021 15:55:43 +0200
2e24b4
Subject: [PATCH 17/19] Modify unit test after change of handling advisories
2e24b4
2e24b4
The patch modifies also yaml with multicollection situation by adding
2e24b4
module requires.
2e24b4
---
2e24b4
 data/tests/advisories/modules.yaml            |   6 +++++
2e24b4
 .../tests/advisories/repodata/modules.yaml.gz | Bin 300 -> 332 bytes
2e24b4
 data/tests/advisories/repodata/primary.xml.gz | Bin 743 -> 743 bytes
2e24b4
 data/tests/advisories/repodata/repomd.xml     |  24 +++++++++---------
2e24b4
 tests/libdnf/sack/AdvisoryTest.cpp            |  22 ++++++----------
2e24b4
 tests/libdnf/sack/QueryTest.cpp               |  24 ++++++++----------
2e24b4
 6 files changed, 37 insertions(+), 39 deletions(-)
2e24b4
2e24b4
diff --git a/data/tests/advisories/modules.yaml b/data/tests/advisories/modules.yaml
2e24b4
index 6db5053a..b5f23f7d 100644
2e24b4
--- a/data/tests/advisories/modules.yaml
2e24b4
+++ b/data/tests/advisories/modules.yaml
2e24b4
@@ -32,6 +32,9 @@ data:
2e24b4
   license:
2e24b4
     module:
2e24b4
     - MIT
2e24b4
+  dependencies:
2e24b4
+  - requires:
2e24b4
+      perl: ["5.23"]
2e24b4
   profiles:
2e24b4
     default:
2e24b4
       rpms: ["test-perl-DBI"]
2e24b4
@@ -52,6 +55,9 @@ data:
2e24b4
   license:
2e24b4
     module:
2e24b4
     - MIT
2e24b4
+  dependencies:
2e24b4
+  - requires:
2e24b4
+      perl: ["5.25"]
2e24b4
   profiles:
2e24b4
     default:
2e24b4
       rpms: ["test-perl-DBI"]
2e24b4
diff --git a/data/tests/advisories/repodata/modules.yaml.gz b/data/tests/advisories/repodata/modules.yaml.gz
2e24b4
index 7158e6c515720c87373762d722e9c438ac7fd8d3..ed39532dfcdec084a661d51d86e07bd3e4246f69 100644
2e24b4
GIT binary patch
2e24b4
literal 332
2e24b4
zcmV-S0ki%eiwFP!000001I>{=Ps1<}hWGr6Q`gE7ag#Rnz<^jfATh8ZR2}w3Sc;us
2e24b4
zJE;77+&V2`Kt&yZ?cV$H`F$8;nd;<V$OZwXQ$tHeWpCuX?yLZwDGVqw0E>nM^yJzo
2e24b4
zd~k$Dz^uyoVipspfg%do*+9Fv4>2lq@
2e24b4
zj-^&hvYx~tmu^cjgS*W`jC$8Kx+R~oiW(f+kOYA1jX%Z=0{Otk>(K?>pbTUAvvJbK
2e24b4
zu0;G>$%;HZyrs6DS4GX|H7^S!#q;q?d7fwN0vp-w&1Pz)K_AF{F_TZt
2e24b4
z=vY2$s-m8(A}e(=mVu+!K|4CRxxZe(
2e24b4
eejSDUe<-TIL$NBWgd)&lisAzcI?AeD1ONa}51~l_
2e24b4
2e24b4
literal 300
2e24b4
zcmV+{0n`2;iwFP!000001Kp56Ps1<}#rJ%QQ`g85ar4LZz<^jfATh94hka2a*-2zO
2e24b4
zsC;`&okAE82nhzZd++X^&p*akrbjhf8iE8n>e-Oh*%LY6kAnoBX$&YcfB`K@n8=wZ
2e24b4
zd~k$T!lo|xb`y=ag)#~?4uMWF4>2lq>L}qPnnP2)uFlq?dzNsYqBMEs`YD{ZuUT~9
2e24b4
z(lWiG!IM0D>9$lexZ6L(YI0-O8}iB3)ZuJG5&&+p{!%jt
2e24b4
zCF9>JRu<{u0~wLmrQo^XRf(i|v3#j0ij4gLBfGuXuTfg`f!qg}d<~O7egSg{{0!*Q
2e24b4
y{uQW8_P4;s(FnI>d`-5gMVs$LyTi`ae@<5YXR>WoC$fRIYqBpd!@UUm0{{Tgm5(X_
2e24b4
2e24b4
diff --git a/data/tests/advisories/repodata/primary.xml.gz b/data/tests/advisories/repodata/primary.xml.gz
2e24b4
index da9ffaf08328659c47be8721a9c478ff64ba0a4d..96cbaa2a5a2361b1e5cd59ddb7de937339982c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468e82 100644
2e24b4
--- a/data/tests/advisories/repodata/repomd.xml
2e24b4
+++ b/data/tests/advisories/repodata/repomd.xml
2e24b4
@@ -1,11 +1,11 @@
2e24b4
 
2e24b4
 <repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
2e24b4
-  <revision>1612879414</revision>
2e24b4
+  <revision>1620890113</revision>
2e24b4
   <data type="primary">
2e24b4
-    <checksum type="sha256">b69e4467719314fdb155872cf9c8e895d5b169c0506c5180c512d693c48f0f4b</checksum>
2e24b4
-    <open-checksum type="sha256">8606d1f777859f167f7bd0bf8a1d532abedcb4db143b719e631e1040800fd1f0</open-checksum>
2e24b4
+    <checksum type="sha256">f2f306a22a157730d2f13f09fc36c425b9bedfc0ecaf74d8b60d98222ebb3274</checksum>
2e24b4
+    <open-checksum type="sha256">ef20a9175429f9f223c4bdcd634fc218bdd85799095438d349efea159cfd2bdf</open-checksum>
2e24b4
     <location href="repodata/primary.xml.gz"/>
2e24b4
-    <timestamp>1612879414</timestamp>
2e24b4
+    <timestamp>1620890113</timestamp>
2e24b4
     <size>743</size>
2e24b4
     <open-size>2665</open-size>
2e24b4
   </data>
2e24b4
@@ -13,7 +13,7 @@
2e24b4
     <checksum type="sha256">efbf7f021163a3c7698a257351e327102c60bb39a7bdceee77c421f064205e99</checksum>
2e24b4
     <open-checksum type="sha256">ca5620e2734574d04d3c01ae5a72f865313369954698d71776076b9cbd831bbd</open-checksum>
2e24b4
     <location href="repodata/filelists.xml.gz"/>
2e24b4
-    <timestamp>1612879414</timestamp>
2e24b4
+    <timestamp>1620890113</timestamp>
2e24b4
     <size>311</size>
2e24b4
     <open-size>511</open-size>
2e24b4
   </data>
2e24b4
@@ -21,23 +21,23 @@
2e24b4
     <checksum type="sha256">6673953e1f28f55b9d4c3f38a9e3c0e0ff88ad06fb693b7f15eb241a81b80d71</checksum>
2e24b4
     <open-checksum type="sha256">0997c242bf1b96372d7a625a73de23dced68cae9375baff0c73215a07693b3f4</open-checksum>
2e24b4
     <location href="repodata/other.xml.gz"/>
2e24b4
-    <timestamp>1612879414</timestamp>
2e24b4
+    <timestamp>1620890113</timestamp>
2e24b4
     <size>310</size>
2e24b4
     <open-size>507</open-size>
2e24b4
   </data>
2e24b4
   <data type="modules">
2e24b4
-    <checksum type="sha256">a815d0669b15b97dd6260713405c79045eeda10aedb6460a0f742b86cc236cca</checksum>
2e24b4
-    <open-checksum type="sha256">0d1063b74e3a7cb4c7cdc3b2080b1901c347693140765534f8c5c3d8b964778a</open-checksum>
2e24b4
+    <checksum type="sha256">df1abc1ab7dacc6ea2bc16c2b14abeb32d0ec9d9ed01378488cec22540f9607b</checksum>
2e24b4
+    <open-checksum type="sha256">f088c4096bfc4acad99a20e06d0d4381872c10f0f27ff8bbfe1bada658ff7afd</open-checksum>
2e24b4
     <location href="repodata/modules.yaml.gz"/>
2e24b4
-    <timestamp>1612879414</timestamp>
2e24b4
-    <size>300</size>
2e24b4
-    <open-size>1019</open-size>
2e24b4
+    <timestamp>1620890113</timestamp>
2e24b4
+    <size>332</size>
2e24b4
+    <open-size>1117</open-size>
2e24b4
   </data>
2e24b4
   <data type="updateinfo">
2e24b4
     <checksum type="sha256">9d791d16c2adc2d7d4c85b45f2a704edac62a926b09fc20df73207f4190acd49</checksum>
2e24b4
     <open-checksum type="sha256">3cf7df860860ac7a4a8e64a1a2d71c1ec43225dacbfe09a0cff80f28be3825da</open-checksum>
2e24b4
     <location href="repodata/updateinfo.xml.gz"/>
2e24b4
-    <timestamp>1612879414</timestamp>
2e24b4
+    <timestamp>1620890113</timestamp>
2e24b4
     <size>708</size>
2e24b4
     <open-size>2414</open-size>
2e24b4
   </data>
2e24b4
diff --git a/tests/libdnf/sack/AdvisoryTest.cpp b/tests/libdnf/sack/AdvisoryTest.cpp
2e24b4
index 805c35da..1abf1a95 100644
2e24b4
--- a/tests/libdnf/sack/AdvisoryTest.cpp
2e24b4
+++ b/tests/libdnf/sack/AdvisoryTest.cpp
2e24b4
@@ -97,11 +97,9 @@ void AdvisoryTest::testGetApplicablePackagesModulesNotSetup()
2e24b4
 
2e24b4
     // When modules are not setup all advisory collections are applicable and we get all packages
2e24b4
     advisory->getApplicablePackages(pkgsvector);
2e24b4
-    CPPUNIT_ASSERT(pkgsvector.size() == 4);
2e24b4
+    CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(pkgsvector.size()));
2e24b4
     CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[3].getNameString(), "not-present"));
2e24b4
+    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "not-present"));
2e24b4
 }
2e24b4
 
2e24b4
 void AdvisoryTest::testGetApplicablePackagesModulesSetupNoneEnabled()
2e24b4
@@ -122,16 +120,14 @@ void AdvisoryTest::testGetApplicablePackagesOneApplicableCollection()
2e24b4
 {
2e24b4
     std::vector<libdnf::AdvisoryPkg> pkgsvector;
2e24b4
 
2e24b4
-    // When I keep enabled only perl-DBI module I get packages from all collections that contain that module
2e24b4
+    // When I keep enabled only perl module I get packages from all collections that contain that module
2e24b4
     libdnf::ModulePackageContainer * modules = dnf_sack_get_module_container(sack);
2e24b4
-    modules->reset("perl");
2e24b4
+    modules->reset("perl-DBI");
2e24b4
     dnf_sack_filter_modules_v2(sack, modules, nullptr, tmpdir, nullptr, true, false, false);
2e24b4
 
2e24b4
     advisory->getApplicablePackages(pkgsvector);
2e24b4
-    CPPUNIT_ASSERT(pkgsvector.size() == 3);
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
2e24b4
+    CPPUNIT_ASSERT(pkgsvector.size() == 1);
2e24b4
+    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "not-present"));
2e24b4
 }
2e24b4
 
2e24b4
 void AdvisoryTest::testGetApplicablePackagesMultipleApplicableCollections()
2e24b4
@@ -141,11 +137,9 @@ void AdvisoryTest::testGetApplicablePackagesMultipleApplicableCollections()
2e24b4
     // When I enable modules from multiple collections -> I get packages from all applicable collections
2e24b4
     // Enabled - "perl-DBI:master", "perl:5.23"
2e24b4
     advisory->getApplicablePackages(pkgsvector);
2e24b4
-    CPPUNIT_ASSERT(pkgsvector.size() == 4);
2e24b4
+    CPPUNIT_ASSERT(pkgsvector.size() == 2);
2e24b4
     CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[3].getNameString(), "not-present"));
2e24b4
+    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "not-present"));
2e24b4
 }
2e24b4
 
2e24b4
 void AdvisoryTest::testGetModules()
2e24b4
diff --git a/tests/libdnf/sack/QueryTest.cpp b/tests/libdnf/sack/QueryTest.cpp
2e24b4
index 7c3a22af..d4cc28c2 100644
2e24b4
--- a/tests/libdnf/sack/QueryTest.cpp
2e24b4
+++ b/tests/libdnf/sack/QueryTest.cpp
2e24b4
@@ -59,12 +59,13 @@ void QueryTest::testQueryGetAdvisoryPkgs()
2e24b4
     HyQuery query = new libdnf::Query(sack);
2e24b4
     std::vector<libdnf::AdvisoryPkg> advisoryPkgs;
2e24b4
 
2e24b4
-    // When modules are not setup all advisory collections are applicable
2e24b4
+    // Apply advisory only from active context - receave advisory package only from releted collection
2e24b4
     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
2e24b4
-    CPPUNIT_ASSERT(advisoryPkgs.size() == 2);
2e24b4
-    // We get test-perl-DBI twice because its in two collections
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[0].getNameString(), "test-perl-DBI"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
2e24b4
+    CPPUNIT_ASSERT(advisoryPkgs.size() == 1);
2e24b4
+
2e24b4
+    CPPUNIT_ASSERT_EQUAL(std::string("test-perl-DBI"), std::string(advisoryPkgs[0].getNameString()));
2e24b4
+    CPPUNIT_ASSERT_EQUAL(std::string("1-2.module_el8+6587+9879afr5"), std::string(advisoryPkgs[0].getEVRString()));
2e24b4
+    //CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
2e24b4
 
2e24b4
     // When modules are setup but none are enabled all collections are not applicable - no enabled module
2e24b4
     libdnf::ModulePackageContainer * modules = dnf_sack_get_module_container(sack);
2e24b4
@@ -84,15 +85,15 @@ void QueryTest::testQueryGetAdvisoryPkgs()
2e24b4
     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
2e24b4
     CPPUNIT_ASSERT(advisoryPkgs.size() == 0);
2e24b4
 
2e24b4
-    // When I enable a module from multiple collections that contain a present package I get them
2e24b4
+    // When I enable a module with multiple collections I will receave advisory packages only for active context
2e24b4
     CPPUNIT_ASSERT(modules->enable("perl-DBI", "master", false));
2e24b4
     dnf_sack_filter_modules_v2(sack, modules, nullptr, tmpdir, nullptr, true, false, false);
2e24b4
 
2e24b4
     advisoryPkgs.clear();
2e24b4
     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
2e24b4
-    CPPUNIT_ASSERT(advisoryPkgs.size() == 2);
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[0].getNameString(), "test-perl-DBI"));
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
2e24b4
+    CPPUNIT_ASSERT(advisoryPkgs.size() == 1);
2e24b4
+    CPPUNIT_ASSERT_EQUAL(std::string("test-perl-DBI"), std::string(advisoryPkgs[0].getNameString()));
2e24b4
+    CPPUNIT_ASSERT_EQUAL(std::string("1-2.module_el8+6587+9879afr5"), std::string(advisoryPkgs[0].getEVRString()));
2e24b4
 
2e24b4
     delete query;
2e24b4
 }
2e24b4
@@ -102,16 +103,13 @@ void QueryTest::testQueryFilterAdvisory()
2e24b4
     // When modules are not setup all advisory collections are applicable and there is no modular filtering
2e24b4
     HyQuery query = new libdnf::Query(sack);
2e24b4
     query->addFilter(HY_PKG_ADVISORY_TYPE, HY_EQ, "enhancement");
2e24b4
-    CPPUNIT_ASSERT(query->size() == 2);
2e24b4
+    CPPUNIT_ASSERT(query->size() == 1);
2e24b4
 
2e24b4
     // We get test-perl-DBI twice because its in two collections
2e24b4
     libdnf::PackageSet pset = *(query->getResultPset());
2e24b4
     DnfPackage *pkg = dnf_package_new(sack, pset[0]);
2e24b4
     CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
2e24b4
     g_object_unref(pkg);
2e24b4
-    pkg = dnf_package_new(sack, pset[1]);
2e24b4
-    CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
2e24b4
-    g_object_unref(pkg);
2e24b4
     delete query;
2e24b4
 
2e24b4
     // When module are setup but none are enabled all collections are not applicable - no enabled module
2e24b4
-- 
2e24b4
2.31.1
2e24b4