2023-05-31 18:29:17 +00:00
|
|
|
# MIT licensed
|
|
|
|
# Copyright (c) 2023 Pekka Ristola <pekkarr [at] protonmail [dot] com>, et al.
|
|
|
|
|
2023-06-19 14:03:48 +00:00
|
|
|
import pathlib
|
2023-05-31 18:29:17 +00:00
|
|
|
import shutil
|
2023-06-19 14:03:48 +00:00
|
|
|
import subprocess
|
|
|
|
import tempfile
|
2023-05-31 18:29:17 +00:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
pytestmark = [
|
2023-12-09 11:17:31 +00:00
|
|
|
pytest.mark.asyncio(scope="session"),
|
2023-05-31 18:29:17 +00:00
|
|
|
pytest.mark.skipif(shutil.which('pacman') is None, reason='requires pacman command'),
|
2023-06-19 14:03:48 +00:00
|
|
|
pytest.mark.skipif(shutil.which('fakeroot') is None, reason='requires fakeroot command'),
|
2023-05-31 18:29:17 +00:00
|
|
|
]
|
|
|
|
|
2023-06-19 14:03:48 +00:00
|
|
|
global temp_dir, db_path
|
|
|
|
|
|
|
|
|
|
|
|
def setup_module(module):
|
|
|
|
global temp_dir, db_path
|
|
|
|
|
|
|
|
temp_dir = tempfile.TemporaryDirectory()
|
|
|
|
temp_path = pathlib.Path(temp_dir.name)
|
|
|
|
db_path = temp_path / 'test-db'
|
|
|
|
|
|
|
|
db_path.mkdir(exist_ok=True)
|
|
|
|
|
|
|
|
cmd = ['fakeroot', 'pacman', '-Fy', '--dbpath', db_path]
|
|
|
|
subprocess.check_call(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
def teardown_module(module):
|
|
|
|
temp_dir.cleanup()
|
|
|
|
|
|
|
|
|
2023-05-31 18:29:17 +00:00
|
|
|
async def test_alpmfiles(get_version):
|
|
|
|
assert await get_version('test', {
|
|
|
|
'source': 'alpmfiles',
|
|
|
|
'pkgname': 'libuv',
|
|
|
|
'filename': 'usr/lib/libuv\\.so\\.([^.]+)',
|
2023-06-19 14:03:48 +00:00
|
|
|
'dbpath': db_path,
|
2023-05-31 18:29:17 +00:00
|
|
|
}) == '1'
|
|
|
|
|
|
|
|
async def test_alpmfiles_strip(get_version):
|
|
|
|
assert await get_version('test', {
|
|
|
|
'source': 'alpmfiles',
|
|
|
|
'pkgname': 'glibc',
|
|
|
|
'repo': 'core',
|
|
|
|
'filename': 'libc\\.so\\.[^.]+',
|
|
|
|
'strip_dir': True,
|
2023-06-19 14:03:48 +00:00
|
|
|
'dbpath': db_path,
|
2023-05-31 18:29:17 +00:00
|
|
|
}) == 'libc.so.6'
|