richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0017-Set-persistdir-for-fill-sack-from-repos-in-cache-tests-RhBug-1865803.patch

31f77b
From 40e762da5cd2d876b6424f4c25b77e8dc2422a0f Mon Sep 17 00:00:00 2001
31f77b
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
31f77b
Date: Mon, 8 Feb 2021 08:25:46 +0100
31f77b
Subject: [PATCH] Set persistdir and substitutions for
31f77b
 fill_sack_from_repos_in_cache tests (RhBug:1865803)
31f77b
31f77b
Setting just installroot is not enough because persistdir is not
31f77b
automatically prepended with installroot if set via API.
31f77b
31f77b
Also assert exact package names which is more useful output in case the
31f77b
test fails.
31f77b
31f77b
https://bugzilla.redhat.com/show_bug.cgi?id=1865803
31f77b
---
31f77b
 tests/test_fill_sack_from_repos_in_cache.py | 19 +++++++++++++++----
31f77b
 1 file changed, 15 insertions(+), 4 deletions(-)
31f77b
31f77b
diff --git a/tests/test_fill_sack_from_repos_in_cache.py b/tests/test_fill_sack_from_repos_in_cache.py
31f77b
index f27235bf84..23fd2a4337 100644
31f77b
--- a/tests/test_fill_sack_from_repos_in_cache.py
31f77b
+++ b/tests/test_fill_sack_from_repos_in_cache.py
31f77b
@@ -42,7 +42,10 @@ class FillSackFromReposInCacheTest(unittest.TestCase):
31f77b
     def _create_cache_for_repo(self, repopath, tmpdir):
31f77b
         conf = dnf.conf.MainConf()
31f77b
         conf.cachedir = os.path.join(tmpdir, "cache")
31f77b
-        conf.installroot = os.path.join(tmpdir)
31f77b
+        conf.installroot = tmpdir
31f77b
+        conf.persistdir = os.path.join(conf.installroot, conf.persistdir.lstrip("/"))
31f77b
+        conf.substitutions["arch"] = "x86_64"
31f77b
+        conf.substitutions["basearch"] = dnf.rpm.basearch(conf.substitutions["arch"])
31f77b
 
31f77b
         base = dnf.Base(conf=conf)
31f77b
 
31f77b
@@ -69,7 +72,10 @@ def _setUp_from_repo_path(self, original_repo_path):
31f77b
         # Prepare base for the actual test
31f77b
         conf = dnf.conf.MainConf()
31f77b
         conf.cachedir = os.path.join(self.tmpdir, "cache")
31f77b
-        conf.installroot = os.path.join(self.tmpdir)
31f77b
+        conf.installroot = self.tmpdir
31f77b
+        conf.persistdir = os.path.join(conf.installroot, conf.persistdir.lstrip("/"))
31f77b
+        conf.substitutions["arch"] = "x86_64"
31f77b
+        conf.substitutions["basearch"] = dnf.rpm.basearch(conf.substitutions["arch"])
31f77b
         self.test_base = dnf.Base(conf=conf)
31f77b
         repoconf = dnf.repo.Repo(TEST_REPO_NAME, conf)
31f77b
         repoconf.baseurl = self.repo_copy_path
31f77b
@@ -231,8 +237,13 @@ def test_with_modules_yaml(self):
31f77b
 
31f77b
         q = self.test_base.sack.query()
31f77b
         packages = q.run()
31f77b
-        self.assertEqual(len(packages), 8)
31f77b
-        self.assertEqual(packages[0].evr, "2.02-0.40")
31f77b
+
31f77b
+        pkg_names = []
31f77b
+        for pkg in packages:
31f77b
+            pkg_names.append(pkg.name)
31f77b
+
31f77b
+        self.assertEqual(pkg_names, ['grub2', 'httpd', 'httpd', 'httpd-doc', 'httpd-doc', 'httpd-provides-name-doc',
31f77b
+                                     'httpd-provides-name-version-release-doc', 'libnghttp2'])
31f77b
 
31f77b
         self.module_base = dnf.module.module_base.ModuleBase(self.test_base)
31f77b
         modules, _ = self.module_base._get_modules("base-runtime*")