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

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