feat(git-proxy): stop 只杀本 CLI 启的 fastgithub,并入 en0 主 LAN IP 供 Parallels 桥接
This commit is contained in:
@@ -85,3 +85,31 @@ def test_restore_stale_git_proxy_noop_when_alive(monkeypatch):
|
||||
)
|
||||
assert _restore_stale_git_proxy() is False
|
||||
assert restored == {}
|
||||
|
||||
|
||||
def test_parallels_host_ips_includes_lan(monkeypatch):
|
||||
from mytoolkit.commands.git import _parallels_host_ips
|
||||
|
||||
monkeypatch.setattr("mytoolkit.commands.git.sys.platform", "darwin")
|
||||
monkeypatch.delenv("XIAOHE_CI_PARALLELS_HOST_IP", raising=False)
|
||||
monkeypatch.setattr(
|
||||
"mytoolkit.commands.git.subprocess.check_output",
|
||||
lambda *a, **k: "inet 10.211.55.2 netmask\n",
|
||||
)
|
||||
monkeypatch.setattr("mytoolkit.commands.git._primary_lan_ip", lambda: "192.168.1.168")
|
||||
assert _parallels_host_ips() == ["10.211.55.2", "192.168.1.168"]
|
||||
|
||||
|
||||
def test_should_kill_proxy_only_if_we_spawned():
|
||||
from mytoolkit.commands.git import _should_kill_proxy_process
|
||||
|
||||
assert _should_kill_proxy_process(None, "fastgithub") is False
|
||||
assert _should_kill_proxy_process({"name": "other"}, "fastgithub") is False
|
||||
assert _should_kill_proxy_process(
|
||||
{"name": "fastgithub", "adopted": True}, "fastgithub"
|
||||
) is False
|
||||
assert _should_kill_proxy_process(
|
||||
{"name": "fastgithub", "adopted": False}, "fastgithub"
|
||||
) is True
|
||||
# Old state files without adopted: keep previous stop-kills-daemon behavior
|
||||
assert _should_kill_proxy_process({"name": "fastgithub"}, "fastgithub") is True
|
||||
|
||||
Reference in New Issue
Block a user