dcavalca / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

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

379fd8
From a61b0105aafeea8487902463f789e6ed00021eb3 Mon Sep 17 00:00:00 2001
379fd8
From: Jaroslav Mracek <jmracek@redhat.com>
379fd8
Date: Wed, 5 May 2021 15:55:43 +0200
379fd8
Subject: [PATCH 17/19] Modify unit test after change of handling advisories
379fd8
379fd8
The patch modifies also yaml with multicollection situation by adding
379fd8
module requires.
379fd8
---
379fd8
 data/tests/advisories/modules.yaml            |   6 +++++
379fd8
 .../tests/advisories/repodata/modules.yaml.gz | Bin 300 -> 332 bytes
379fd8
 data/tests/advisories/repodata/primary.xml.gz | Bin 743 -> 743 bytes
379fd8
 data/tests/advisories/repodata/repomd.xml     |  24 +++++++++---------
379fd8
 tests/libdnf/sack/AdvisoryTest.cpp            |  22 ++++++----------
379fd8
 tests/libdnf/sack/QueryTest.cpp               |  24 ++++++++----------
379fd8
 6 files changed, 37 insertions(+), 39 deletions(-)
379fd8
379fd8
diff --git a/data/tests/advisories/modules.yaml b/data/tests/advisories/modules.yaml
379fd8
index 6db5053a..b5f23f7d 100644
379fd8
--- a/data/tests/advisories/modules.yaml
379fd8
+++ b/data/tests/advisories/modules.yaml
379fd8
@@ -32,6 +32,9 @@ data:
379fd8
   license:
379fd8
     module:
379fd8
     - MIT
379fd8
+  dependencies:
379fd8
+  - requires:
379fd8
+      perl: ["5.23"]
379fd8
   profiles:
379fd8
     default:
379fd8
       rpms: ["test-perl-DBI"]
379fd8
@@ -52,6 +55,9 @@ data:
379fd8
   license:
379fd8
     module:
379fd8
     - MIT
379fd8
+  dependencies:
379fd8
+  - requires:
379fd8
+      perl: ["5.25"]
379fd8
   profiles:
379fd8
     default:
379fd8
       rpms: ["test-perl-DBI"]
379fd8
diff --git a/data/tests/advisories/repodata/modules.yaml.gz b/data/tests/advisories/repodata/modules.yaml.gz
379fd8
index 7158e6c515720c87373762d722e9c438ac7fd8d3..ed39532dfcdec084a661d51d86e07bd3e4246f69 100644
379fd8
GIT binary patch
379fd8
literal 332
379fd8
zcmV-S0ki%eiwFP!000001I>{=Ps1<}hWGr6Q`gE7ag#Rnz<^jfATh8ZR2}w3Sc;us
379fd8
zJE;77+&V2`Kt&yZ?cV$H`F$8;nd;<V$OZwXQ$tHeWpCuX?yLZwDGVqw0E>nM^yJzo
379fd8
zd~k$Dz^uyoVipspfg%do*+9Fv4>2lq@
379fd8
zj-^&hvYx~tmu^cjgS*W`jC$8Kx+R~oiW(f+kOYA1jX%Z=0{Otk>(K?>pbTUAvvJbK
379fd8
zu0;G>$%;HZyrs6DS4GX|H7^S!#q;q?d7fwN0vp-w&1Pz)K_AF{F_TZt
379fd8
z=vY2$s-m8(A}e(=mVu+!K|4CRxxZe(
379fd8
eejSDUe<-TIL$NBWgd)&lisAzcI?AeD1ONa}51~l_
379fd8
379fd8
literal 300
379fd8
zcmV+{0n`2;iwFP!000001Kp56Ps1<}#rJ%QQ`g85ar4LZz<^jfATh94hka2a*-2zO
379fd8
zsC;`&okAE82nhzZd++X^&p*akrbjhf8iE8n>e-Oh*%LY6kAnoBX$&YcfB`K@n8=wZ
379fd8
zd~k$T!lo|xb`y=ag)#~?4uMWF4>2lq>L}qPnnP2)uFlq?dzNsYqBMEs`YD{ZuUT~9
379fd8
z(lWiG!IM0D>9$lexZ6L(YI0-O8}iB3)ZuJG5&&+p{!%jt
379fd8
zCF9>JRu<{u0~wLmrQo^XRf(i|v3#j0ij4gLBfGuXuTfg`f!qg}d<~O7egSg{{0!*Q
379fd8
y{uQW8_P4;s(FnI>d`-5gMVs$LyTi`ae@<5YXR>WoC$fRIYqBpd!@UUm0{{Tgm5(X_
379fd8
379fd8
diff --git a/data/tests/advisories/repodata/primary.xml.gz b/data/tests/advisories/repodata/primary.xml.gz
379fd8
index da9ffaf08328659c47be8721a9c478ff64ba0a4d..96cbaa2a5a2361b1e5cd59ddb7de937339982c5f 100644
379fd8
GIT binary patch
379fd8
liter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
zcmV
379fd8
zBYsV`gJ!>ek{?a7SKDFTPz(qXk^D&NBSj*?`CVC{EvPoHs}Pf=jS*C`PV#CU;*U3P
379fd8
z7al&3PJ$9Tk%&$p4X@e|XI<BvSyqu({oOL@H?V}Hw`P<j>$0pXJfhE3Q$FaSF&H&M
379fd8
zZp0dNe2R6_NkrYQfe;%+bb?S&i4vj?+HTQ+Di&`pt^#Y&8KY1#i|#z<)?tA)2u3>*
379fd8
zM9|bS3$Z4tHJUC)3JRTVS=LEkz%3Nsslz?@)c0Ipq>5u}@Ru3LP1~2#RoYBY?&$k&
379fd8
z)_D@*PnXv?TBZJq`EKG-%311D!8}P_NH~XBau2*Db{L^t8)G6Eje)qtCg3nXb-~lO
379fd8
zos$e1^=~QEZs4iYp!Z`f0&6xHPy($~dDCfX(aBAgw@7~kn#+QW^IX)xIznsj$)KXZ
379fd8
zx<49yuL`X)-$v^45>T2Knl^C=^<0m+ntI&lg{Drp$9=*mp;M*W{0qz}L+scd!zi!X
379fd8
zP80
379fd8
zY9V@ebrV>JialftRZ^QW90+^sTGf3MUGLfsN_1Imb5&O*RGoDpS{Qvs$lhfrPFA;F
379fd8
zWSAA^Gy?aAJ-DrVB|)E}C-82SG^EF<`w07}8HfbbLWxQbkS@RKLd>|$%y=iJG0Yw-
379fd8
zHsKppZ*%=ZM%AR$EY%K~+4`m_7^Q_+>p8vrfPZ(W9?tSgcX#2i*MBD4SgT{6Lw*IH
379fd8
z`&>PS`mZj+m-BO;Qys<)todQy58J<6a4zFxbvjr*e!&Uh5hqUVSOTQnr7=q=lO*+p
379fd8
z4>7SNb+`^p#EPffcUCdj5`2%Qv6H$!WzLIUaJIAhYYXnMJ^#~!JL3J~7Totk^_&at
379fd8
ZN7
379fd8
379fd8
diff --git a/data/tests/advisories/repodata/repomd.xml b/data/tests/advisories/repodata/repomd.xml
379fd8
index 21630e04..c9468e82 100644
379fd8
--- a/data/tests/advisories/repodata/repomd.xml
379fd8
+++ b/data/tests/advisories/repodata/repomd.xml
379fd8
@@ -1,11 +1,11 @@
379fd8
 
379fd8
 <repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
379fd8
-  <revision>1612879414</revision>
379fd8
+  <revision>1620890113</revision>
379fd8
   <data type="primary">
379fd8
-    <checksum type="sha256">b69e4467719314fdb155872cf9c8e895d5b169c0506c5180c512d693c48f0f4b</checksum>
379fd8
-    <open-checksum type="sha256">8606d1f777859f167f7bd0bf8a1d532abedcb4db143b719e631e1040800fd1f0</open-checksum>
379fd8
+    <checksum type="sha256">f2f306a22a157730d2f13f09fc36c425b9bedfc0ecaf74d8b60d98222ebb3274</checksum>
379fd8
+    <open-checksum type="sha256">ef20a9175429f9f223c4bdcd634fc218bdd85799095438d349efea159cfd2bdf</open-checksum>
379fd8
     <location href="repodata/primary.xml.gz"/>
379fd8
-    <timestamp>1612879414</timestamp>
379fd8
+    <timestamp>1620890113</timestamp>
379fd8
     <size>743</size>
379fd8
     <open-size>2665</open-size>
379fd8
   </data>
379fd8
@@ -13,7 +13,7 @@
379fd8
     <checksum type="sha256">efbf7f021163a3c7698a257351e327102c60bb39a7bdceee77c421f064205e99</checksum>
379fd8
     <open-checksum type="sha256">ca5620e2734574d04d3c01ae5a72f865313369954698d71776076b9cbd831bbd</open-checksum>
379fd8
     <location href="repodata/filelists.xml.gz"/>
379fd8
-    <timestamp>1612879414</timestamp>
379fd8
+    <timestamp>1620890113</timestamp>
379fd8
     <size>311</size>
379fd8
     <open-size>511</open-size>
379fd8
   </data>
379fd8
@@ -21,23 +21,23 @@
379fd8
     <checksum type="sha256">6673953e1f28f55b9d4c3f38a9e3c0e0ff88ad06fb693b7f15eb241a81b80d71</checksum>
379fd8
     <open-checksum type="sha256">0997c242bf1b96372d7a625a73de23dced68cae9375baff0c73215a07693b3f4</open-checksum>
379fd8
     <location href="repodata/other.xml.gz"/>
379fd8
-    <timestamp>1612879414</timestamp>
379fd8
+    <timestamp>1620890113</timestamp>
379fd8
     <size>310</size>
379fd8
     <open-size>507</open-size>
379fd8
   </data>
379fd8
   <data type="modules">
379fd8
-    <checksum type="sha256">a815d0669b15b97dd6260713405c79045eeda10aedb6460a0f742b86cc236cca</checksum>
379fd8
-    <open-checksum type="sha256">0d1063b74e3a7cb4c7cdc3b2080b1901c347693140765534f8c5c3d8b964778a</open-checksum>
379fd8
+    <checksum type="sha256">df1abc1ab7dacc6ea2bc16c2b14abeb32d0ec9d9ed01378488cec22540f9607b</checksum>
379fd8
+    <open-checksum type="sha256">f088c4096bfc4acad99a20e06d0d4381872c10f0f27ff8bbfe1bada658ff7afd</open-checksum>
379fd8
     <location href="repodata/modules.yaml.gz"/>
379fd8
-    <timestamp>1612879414</timestamp>
379fd8
-    <size>300</size>
379fd8
-    <open-size>1019</open-size>
379fd8
+    <timestamp>1620890113</timestamp>
379fd8
+    <size>332</size>
379fd8
+    <open-size>1117</open-size>
379fd8
   </data>
379fd8
   <data type="updateinfo">
379fd8
     <checksum type="sha256">9d791d16c2adc2d7d4c85b45f2a704edac62a926b09fc20df73207f4190acd49</checksum>
379fd8
     <open-checksum type="sha256">3cf7df860860ac7a4a8e64a1a2d71c1ec43225dacbfe09a0cff80f28be3825da</open-checksum>
379fd8
     <location href="repodata/updateinfo.xml.gz"/>
379fd8
-    <timestamp>1612879414</timestamp>
379fd8
+    <timestamp>1620890113</timestamp>
379fd8
     <size>708</size>
379fd8
     <open-size>2414</open-size>
379fd8
   </data>
379fd8
diff --git a/tests/libdnf/sack/AdvisoryTest.cpp b/tests/libdnf/sack/AdvisoryTest.cpp
379fd8
index 805c35da..1abf1a95 100644
379fd8
--- a/tests/libdnf/sack/AdvisoryTest.cpp
379fd8
+++ b/tests/libdnf/sack/AdvisoryTest.cpp
379fd8
@@ -97,11 +97,9 @@ void AdvisoryTest::testGetApplicablePackagesModulesNotSetup()
379fd8
 
379fd8
     // When modules are not setup all advisory collections are applicable and we get all packages
379fd8
     advisory->getApplicablePackages(pkgsvector);
379fd8
-    CPPUNIT_ASSERT(pkgsvector.size() == 4);
379fd8
+    CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(pkgsvector.size()));
379fd8
     CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[3].getNameString(), "not-present"));
379fd8
+    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "not-present"));
379fd8
 }
379fd8
 
379fd8
 void AdvisoryTest::testGetApplicablePackagesModulesSetupNoneEnabled()
379fd8
@@ -122,16 +120,14 @@ void AdvisoryTest::testGetApplicablePackagesOneApplicableCollection()
379fd8
 {
379fd8
     std::vector<libdnf::AdvisoryPkg> pkgsvector;
379fd8
 
379fd8
-    // When I keep enabled only perl-DBI module I get packages from all collections that contain that module
379fd8
+    // When I keep enabled only perl module I get packages from all collections that contain that module
379fd8
     libdnf::ModulePackageContainer * modules = dnf_sack_get_module_container(sack);
379fd8
-    modules->reset("perl");
379fd8
+    modules->reset("perl-DBI");
379fd8
     dnf_sack_filter_modules_v2(sack, modules, nullptr, tmpdir, nullptr, true, false, false);
379fd8
 
379fd8
     advisory->getApplicablePackages(pkgsvector);
379fd8
-    CPPUNIT_ASSERT(pkgsvector.size() == 3);
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
379fd8
+    CPPUNIT_ASSERT(pkgsvector.size() == 1);
379fd8
+    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "not-present"));
379fd8
 }
379fd8
 
379fd8
 void AdvisoryTest::testGetApplicablePackagesMultipleApplicableCollections()
379fd8
@@ -141,11 +137,9 @@ void AdvisoryTest::testGetApplicablePackagesMultipleApplicableCollections()
379fd8
     // When I enable modules from multiple collections -> I get packages from all applicable collections
379fd8
     // Enabled - "perl-DBI:master", "perl:5.23"
379fd8
     advisory->getApplicablePackages(pkgsvector);
379fd8
-    CPPUNIT_ASSERT(pkgsvector.size() == 4);
379fd8
+    CPPUNIT_ASSERT(pkgsvector.size() == 2);
379fd8
     CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[3].getNameString(), "not-present"));
379fd8
+    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "not-present"));
379fd8
 }
379fd8
 
379fd8
 void AdvisoryTest::testGetModules()
379fd8
diff --git a/tests/libdnf/sack/QueryTest.cpp b/tests/libdnf/sack/QueryTest.cpp
379fd8
index 7c3a22af..d4cc28c2 100644
379fd8
--- a/tests/libdnf/sack/QueryTest.cpp
379fd8
+++ b/tests/libdnf/sack/QueryTest.cpp
379fd8
@@ -59,12 +59,13 @@ void QueryTest::testQueryGetAdvisoryPkgs()
379fd8
     HyQuery query = new libdnf::Query(sack);
379fd8
     std::vector<libdnf::AdvisoryPkg> advisoryPkgs;
379fd8
 
379fd8
-    // When modules are not setup all advisory collections are applicable
379fd8
+    // Apply advisory only from active context - receave advisory package only from releted collection
379fd8
     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
379fd8
-    CPPUNIT_ASSERT(advisoryPkgs.size() == 2);
379fd8
-    // We get test-perl-DBI twice because its in two collections
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[0].getNameString(), "test-perl-DBI"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
379fd8
+    CPPUNIT_ASSERT(advisoryPkgs.size() == 1);
379fd8
+
379fd8
+    CPPUNIT_ASSERT_EQUAL(std::string("test-perl-DBI"), std::string(advisoryPkgs[0].getNameString()));
379fd8
+    CPPUNIT_ASSERT_EQUAL(std::string("1-2.module_el8+6587+9879afr5"), std::string(advisoryPkgs[0].getEVRString()));
379fd8
+    //CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
379fd8
 
379fd8
     // When modules are setup but none are enabled all collections are not applicable - no enabled module
379fd8
     libdnf::ModulePackageContainer * modules = dnf_sack_get_module_container(sack);
379fd8
@@ -84,15 +85,15 @@ void QueryTest::testQueryGetAdvisoryPkgs()
379fd8
     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
379fd8
     CPPUNIT_ASSERT(advisoryPkgs.size() == 0);
379fd8
 
379fd8
-    // When I enable a module from multiple collections that contain a present package I get them
379fd8
+    // When I enable a module with multiple collections I will receave advisory packages only for active context
379fd8
     CPPUNIT_ASSERT(modules->enable("perl-DBI", "master", false));
379fd8
     dnf_sack_filter_modules_v2(sack, modules, nullptr, tmpdir, nullptr, true, false, false);
379fd8
 
379fd8
     advisoryPkgs.clear();
379fd8
     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
379fd8
-    CPPUNIT_ASSERT(advisoryPkgs.size() == 2);
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[0].getNameString(), "test-perl-DBI"));
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
379fd8
+    CPPUNIT_ASSERT(advisoryPkgs.size() == 1);
379fd8
+    CPPUNIT_ASSERT_EQUAL(std::string("test-perl-DBI"), std::string(advisoryPkgs[0].getNameString()));
379fd8
+    CPPUNIT_ASSERT_EQUAL(std::string("1-2.module_el8+6587+9879afr5"), std::string(advisoryPkgs[0].getEVRString()));
379fd8
 
379fd8
     delete query;
379fd8
 }
379fd8
@@ -102,16 +103,13 @@ void QueryTest::testQueryFilterAdvisory()
379fd8
     // When modules are not setup all advisory collections are applicable and there is no modular filtering
379fd8
     HyQuery query = new libdnf::Query(sack);
379fd8
     query->addFilter(HY_PKG_ADVISORY_TYPE, HY_EQ, "enhancement");
379fd8
-    CPPUNIT_ASSERT(query->size() == 2);
379fd8
+    CPPUNIT_ASSERT(query->size() == 1);
379fd8
 
379fd8
     // We get test-perl-DBI twice because its in two collections
379fd8
     libdnf::PackageSet pset = *(query->getResultPset());
379fd8
     DnfPackage *pkg = dnf_package_new(sack, pset[0]);
379fd8
     CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
379fd8
     g_object_unref(pkg);
379fd8
-    pkg = dnf_package_new(sack, pset[1]);
379fd8
-    CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
379fd8
-    g_object_unref(pkg);
379fd8
     delete query;
379fd8
 
379fd8
     // When module are setup but none are enabled all collections are not applicable - no enabled module
379fd8
-- 
379fd8
2.31.1
379fd8