From 9aabfafc2fce61e6c656e67332d01e42e279d7b8 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Mon, 9 May 2022 16:57:55 -0700 Subject: [PATCH] add a test for the 'autoinstalled' file not existing --- pytests/tests/test_autoremove.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pytests/tests/test_autoremove.py b/pytests/tests/test_autoremove.py index 7c9ae167..e7916527 100644 --- a/pytests/tests/test_autoremove.py +++ b/pytests/tests/test_autoremove.py @@ -192,3 +192,33 @@ def test_autoremove_conf_false_autoremove(utils): assert(not utils.check_package(pkgname)) # actual test: assert(not utils.check_package(pkgname_req)) + + +# check issues with the 'autoinstalled' file not existing +# or the directory (PR #316) +def test_no_autoinstalled_dir(utils): + pkgname = utils.config["mulversion_pkgname"] + utils.install_package(pkgname) + os.rename('/var/lib/tdnf', '/var/lib/tdnf.away') + ret = utils.run(['tdnf', '-y', 'install', pkgname]) + assert(ret['retval'] == 0) + assert(utils.check_package(pkgname)) + + +def test_no_autoinstalled_file(utils): + pkgname = utils.config["mulversion_pkgname"] + utils.install_package(pkgname) + os.rename('/var/lib/tdnf/autoinstalled', '/var/lib/tdnf/autoinstalled.away') + ret = utils.run(['tdnf', '-y', 'install', pkgname]) + assert(ret['retval'] == 0) + assert(utils.check_package(pkgname)) + + +def test_no_autoinstalled_empty(utils): + pkgname = utils.config["mulversion_pkgname"] + utils.install_package(pkgname) + os.rename('/var/lib/tdnf/autoinstalled', '/var/lib/tdnf/autoinstalled.away') + os.mknod('/var/lib/tdnf/autoinstalled') + ret = utils.run(['tdnf', '-y', 'install', pkgname]) + assert(ret['retval'] == 0) + assert(utils.check_package(pkgname))