diff --git a/pmb/chroot/test_apk.py b/pmb/chroot/test_apk.py new file mode 100644 index 00000000..1b070acc --- /dev/null +++ b/pmb/chroot/test_apk.py @@ -0,0 +1,42 @@ +import pytest + +from pmb.core.arch import Arch +from pmb.core.context import get_context + +from .apk import packages_get_locally_built_apks +import pmb.config.pmaports + +@pytest.fixture +def apk_mocks(monkeypatch): + def _pmaports_config(_aports=None): + return { + "channel": "edge", + } + + monkeypatch.setattr(pmb.config.pmaports, "read_config", _pmaports_config) + + def _apkindex_package(_package, _arch, _must_exist=False, indexes=None): + return { + "name": _package, + "version": "5.5-r0", + "arch": str(_arch), + } + + monkeypatch.setattr(pmb.parse.apkindex, "package", _apkindex_package) + + +def test_get_local_apks(pmb_args, apk_mocks): + """Ensure packages_get_locally_built_apks() returns paths for local apks""" + + pkgname = "hello-world" + arch = Arch.x86_64 + + apk_file = get_context().config.work / "packages" / "edge" / arch / f"{pkgname}-5.5-r0.apk" + apk_file.parent.mkdir(parents=True) + apk_file.touch() + + local = packages_get_locally_built_apks([pkgname, "fake-package"], arch) + print(local) + assert len(local) == 1 + assert local[0].parts[-2:] == apk_file.parts[-2:] + diff --git a/pmb/conftest.py b/pmb/conftest.py index 4fadc398..b8163fa9 100644 --- a/pmb/conftest.py +++ b/pmb/conftest.py @@ -27,7 +27,7 @@ def config_file(tmp_path_factory, request): "no-repos": "aports = "} file = _testdir / "pmbootstrap.cfg" - print(f"config_file: {out_file}") + print(f"CONFIG: {out_file}") cfg = configs[flavour] contents = open(file).read().format(workdir, cfg) @@ -122,8 +122,9 @@ def pmb_args(config_file, mock_context, logfile): args.cross = False args.log = logfile - print("init_args") init_args(args) + + print(f"WORK: {get_context().config.work}") # Sanity check assert ".pytest_tmp" in get_context().config.work.parts