Files
cli-tools/tests/test_tasks.py
T
2026-04-08 00:07:36 +02:00

46 lines
1.7 KiB
Python

import subprocess
def lxc_exec(container: str, cmd: str, check: bool = True) -> subprocess.CompletedProcess:
"""Run a command in the container as the jev user."""
return subprocess.run(
["lxc", "exec", container, "--user", "1000", "--", "bash", "-lc", cmd],
check=check,
)
def run_task(container: str, task: str) -> None:
lxc_exec(container, f"cd /home/jev/cli-tools && invoke {task.replace('_', '-')}")
def test_install_apt_packages(container: str) -> None:
run_task(container, "install_apt_packages")
for binary in ["git", "micro", "tree", "detox"]:
result = lxc_exec(container, f"which {binary}", check=False)
assert result.returncode == 0, f"{binary!r} not found after install_apt_packages"
def test_install_docker(container: str) -> None:
run_task(container, "install_docker")
result = lxc_exec(container, "docker --version", check=False)
assert result.returncode == 0, "docker not found after install_docker"
def test_install_uv(container: str) -> None:
run_task(container, "install_uv")
result = lxc_exec(container, "~/.local/bin/uv --version", check=False)
assert result.returncode == 0, "uv not found after install_uv"
def test_install_fzf(container: str) -> None:
run_task(container, "install_fzf")
for binary in ["fzf", "batcat"]:
result = lxc_exec(container, f"which {binary}", check=False)
assert result.returncode == 0, f"{binary!r} not found after install_fzf"
def test_install_zoxide(container: str) -> None:
run_task(container, "install_zoxide")
result = lxc_exec(container, "which zoxide", check=False)
assert result.returncode == 0, "zoxide not found after install_zoxide"