dcavalca / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0027-Use-environment-variable-in-unittest-instead-of-ugly.patch

2c1f71
From 074ca4cf643c79b8ec3db89a7fd5580ba387eb4d Mon Sep 17 00:00:00 2001
2c1f71
From: Jaroslav Rohel <jrohel@redhat.com>
2c1f71
Date: Wed, 20 Apr 2022 08:22:30 +0200
2c1f71
Subject: [PATCH 27/34] Use environment variable in unittest instead of ugly
2c1f71
 hack in libdnf
2c1f71
2c1f71
Libdnf contains hacks for unit tests. This removes one hack.
2c1f71
---
2c1f71
 libdnf/dnf-repo.cpp          | 3 ---
2c1f71
 tests/libdnf/dnf-self-test.c | 3 +++
2c1f71
 2 files changed, 3 insertions(+), 3 deletions(-)
2c1f71
2c1f71
diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
2c1f71
index 9d42e3e3..c015d7fd 100644
2c1f71
--- a/libdnf/dnf-repo.cpp
2c1f71
+++ b/libdnf/dnf-repo.cpp
2c1f71
@@ -1191,7 +1191,6 @@ dnf_repo_setup(DnfRepo *repo, GError **error) try
2c1f71
     DnfRepoEnabled enabled = DNF_REPO_ENABLED_NONE;
2c1f71
     g_autofree gchar *basearch = NULL;
2c1f71
     g_autofree gchar *release = NULL;
2c1f71
-    g_autofree gchar *testdatadir = NULL;
2c1f71
 
2c1f71
     basearch = g_key_file_get_string(priv->keyfile, "general", "arch", NULL);
2c1f71
     if (basearch == NULL)
2c1f71
@@ -1230,8 +1229,6 @@ dnf_repo_setup(DnfRepo *repo, GError **error) try
2c1f71
     for (const auto & item : libdnf::dnf_context_get_vars(priv->context))
2c1f71
         priv->urlvars = lr_urlvars_set(priv->urlvars, item.first.c_str(), item.second.c_str());
2c1f71
 
2c1f71
-    testdatadir = dnf_realpath(TESTDATADIR);
2c1f71
-    priv->urlvars = lr_urlvars_set(priv->urlvars, "testdatadir", testdatadir);
2c1f71
     if (!lr_handle_setopt(priv->repo_handle, error, LRO_VARSUB, priv->urlvars))
2c1f71
         return FALSE;
2c1f71
     if (!lr_handle_setopt(priv->repo_handle, error, LRO_GNUPGHOMEDIR, priv->keyring))
2c1f71
diff --git a/tests/libdnf/dnf-self-test.c b/tests/libdnf/dnf-self-test.c
2c1f71
index 52958371..906f0e21 100644
2c1f71
--- a/tests/libdnf/dnf-self-test.c
2c1f71
+++ b/tests/libdnf/dnf-self-test.c
2c1f71
@@ -1225,6 +1225,9 @@ main(int argc, char **argv)
2c1f71
     g_log_set_fatal_mask(NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
2c1f71
     g_log_set_always_fatal (G_LOG_FATAL_MASK);
2c1f71
 
2c1f71
+    /* Sets a variable to replace in repository configurations. */
2c1f71
+    g_setenv("DNF_VAR_testdatadir", TESTDATADIR, TRUE);
2c1f71
+
2c1f71
     /* tests go here */
2c1f71
     g_test_add_func("/libdnf/repo_loader{gpg-asc}", dnf_repo_loader_gpg_asc_func);
2c1f71
     g_test_add_func("/libdnf/repo_loader{gpg-wrong-asc}", dnf_repo_loader_gpg_wrong_asc_func);
2c1f71
-- 
2c1f71
2.31.1
2c1f71