Files
myagents/tests/test_version.py
T
Zhengshou Lai d99c5534cb refactor: drop workspace sync launcher path; simplify upgrade/switch
Align with xiaohe wheel/pip install: remove sync_workspace and desktop
launcher coupling from upgrade/switch flows.
2026-07-25 12:43:24 +08:00

51 lines
1.4 KiB
Python

"""Tests for myagents.commands.version."""
import subprocess
from pathlib import Path
from myagents.commands import version as ver_mod
class TestDescribeTree:
def test_legacy_runtime_tree(self) -> None:
tree = Path("/home/u/.xiaohe/runtime/v1.2.3/contrib/myagents")
mode, detail = ver_mod.describe_tree(tree)
assert mode == "legacy-runtime"
assert detail == "v1.2.3"
def test_development_checkout(self, tmp_path: Path) -> None:
repo = tmp_path / "repo"
repo.mkdir()
(repo / ".git").mkdir()
mode, _ = ver_mod.describe_tree(repo)
assert mode == "development"
def test_unknown_tree(self, tmp_path: Path) -> None:
mode, _ = ver_mod.describe_tree(tmp_path)
assert mode == "unknown"
class TestGitDescribe:
def test_describes_real_repo(self, tmp_path: Path) -> None:
repo = tmp_path / "repo"
repo.mkdir()
subprocess.run(["git", "init", "-q"], cwd=repo, check=True)
subprocess.run(
[
"git",
"-c",
"user.email=t@t",
"-c",
"user.name=t",
"commit",
"-q",
"--allow-empty",
"-m",
"init",
],
cwd=repo,
check=True,
)
result = ver_mod._git_describe(repo)
assert result != "unknown"