richardphibel / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0017-Modify-unit-test-after-change-of-handling-advisories.patch

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