47 lines
1.8 KiB
Python
47 lines
1.8 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", "--env", "HOME=/home/jev", "--", "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")
|
|
result = lxc_exec(container, "test -f ~/.fzf/bin/fzf", check=False)
|
|
assert result.returncode == 0, "fzf binary not found at ~/.fzf/bin/fzf after install_fzf"
|
|
result = lxc_exec(container, "which batcat", check=False)
|
|
assert result.returncode == 0, "batcat 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"
|