prole/tests/installer/test_controller_run_script_expands_shell_vars.py
chrisfu c0a7d0c5dc Refine installer orchestration and Supabase rendering paths
- improve installer/action/controller flow and shell-variable expansion handling across screens\n- adjust Supabase Helm rendering and storage deployment templates\n- align monitoring, cloudnative-pg and repair pipeline behavior with updated config paths\n- refresh and expand installer/core regression tests around milestones, navigation and repair logic

Co-authored-by: Junie <junie@jetbrains.com>
2026-03-31 23:15:54 -07:00

31 lines
1006 B
Python

from __future__ import annotations
from pathlib import Path
def test_controller_run_script_expands_shell_vars(monkeypatch, tmp_path: Path):
"""Regression: `run_script` must expand `$HOME`/`$PROLE_HOME` before mkdir/copy.
Without this, setting `PROLE_HOME=$HOME/prole` can create a literal `$HOME`
directory in the current working directory.
"""
monkeypatch.chdir(tmp_path)
home_dir = tmp_path / "home"
home_dir.mkdir(parents=True, exist_ok=True)
monkeypatch.setenv("HOME", str(home_dir))
proj = tmp_path / "project_root"
(proj / "etc").mkdir(parents=True, exist_ok=True)
(proj / "etc" / "dummy.sh").write_text("#!/usr/bin/env bash\necho ok\n")
from knoe.core.controller import KnoeController
controller = KnoeController(project_root=proj)
rc = controller.run_script("dummy.sh", env={"PROLE_HOME": "$HOME/prole"})
assert rc == 0
assert (home_dir / "prole" / "etc" / "dummy.sh").is_file()
assert not (tmp_path / "$HOME").exists()