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

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