mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 11:03:59 +00:00
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
from knoe.ops.context import KnoeContext
|
|
from knoe.ops.legacy_shell import run_script
|
|
|
|
|
|
def test_run_script_argument_assembly(tmp_path: Path):
|
|
etc_dir = tmp_path / "etc"
|
|
etc_dir.mkdir(parents=True, exist_ok=True)
|
|
(etc_dir / "init_argocd.sh").write_text("#!/usr/bin/env bash\necho ok\n", encoding="utf-8")
|
|
|
|
ctx = KnoeContext(
|
|
project_root=tmp_path,
|
|
cfg_path=tmp_path / "conf" / "knoe.cfg",
|
|
mode="m",
|
|
namespace="ns",
|
|
service_namespace="svcns",
|
|
env={"X": "1"},
|
|
)
|
|
|
|
with patch("knoe.ops.legacy_shell.run_streaming", return_value=0) as m:
|
|
rc = run_script(ctx, "init_argocd.sh", "status", extra_args=["--foo", "bar"])
|
|
|
|
assert rc == 0
|
|
(cmd,), kwargs = m.call_args
|
|
assert cmd[0] == "bash"
|
|
assert cmd[2:] == ["status", "--foo", "bar"]
|
|
assert kwargs["cwd"] == tmp_path
|
|
assert kwargs["env"]["X"] == "1"
|
|
assert kwargs["env"]["KNOE_MODE"] == "m"
|
|
assert kwargs["env"]["PROLE_NAMESPACE"] == "ns"
|
|
assert kwargs["env"]["KNOE_SERVICE_NAMESPACE"] == "svcns"
|
|
assert kwargs["env"]["PROLE_CFG"].endswith("conf/knoe.cfg")
|