Skip to content

Commit

Permalink
add test for issue #367
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverkurth committed Nov 16, 2022
1 parent ca9347d commit 3342456
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pytests/tests/test_excludes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#

import pytest
import os
import shutil


@pytest.fixture(scope='module', autouse=True)
Expand All @@ -20,6 +22,23 @@ def teardown_test(utils):
pkgname = utils.config[pkg]
utils.run(['tdnf', 'erase', '-y', pkgname])

dirname = os.path.join(utils.config['repo_path'], 'minversions.d')
if os.path.isdir(dirname):
shutil.rmtree(dirname)

utils.tdnf_config.remove_option('main', 'minversions')
filename = os.path.join(utils.config['repo_path'], 'tdnf.conf')
with open(filename, 'w') as f:
utils.tdnf_config.write(f, space_around_delimiters=False)


def set_minversions_file(utils, value):
dirname = os.path.join(utils.config['repo_path'], 'minversions.d')
utils.makedirs(dirname)
filename = os.path.join(dirname, 'test.conf')
with open(filename, 'w') as f:
f.write(value)


# specifying the version should not override the exclude (negative test)
def test_install_package_with_version_suffix(utils):
Expand Down Expand Up @@ -79,3 +98,27 @@ def test_remove_package(utils):
utils.run(['tdnf', 'remove', '--exclude=', pkgname, '-y', '--nogpgcheck', pkgname])
# package should still be there
assert utils.check_package(pkgname)


# test for issue #367
def test_with_minversion_existing(utils):
mverpkg = utils.config["sglversion_pkgname"]
set_minversions_file(utils, mverpkg + "=1.0.1-2\n")

pkgname = utils.config["mulversion_pkgname"]
pkgversion1 = utils.config["mulversion_lower"]
pkgversion2 = utils.config["mulversion_higher"]

if '-' in pkgversion1:
pkgversion1 = pkgversion1.split('-')[0]
if '-' in pkgversion2:
pkgversion2 = pkgversion2.split('-')[0]

utils.erase_package(pkgname)

utils.run(['tdnf', 'install', '-y', '--nogpgcheck', pkgname + '-' + pkgversion1])
assert utils.check_package(pkgname, pkgversion1)

utils.run(['tdnf', 'update', '--exclude=', '-y', '--nogpgcheck', pkgname + '-' + pkgversion2])
assert not utils.check_package(pkgname, pkgversion2)
assert utils.check_package(pkgname, pkgversion1)

0 comments on commit 3342456

Please sign in to comment.