forked from Mirror/pmbootstrap
tests: add a test for packages_get_locally_built_apks() (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
c89b53a87e
commit
d75f1cf525
2 changed files with 45 additions and 2 deletions
42
pmb/chroot/test_apk.py
Normal file
42
pmb/chroot/test_apk.py
Normal file
|
@ -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:]
|
||||
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue