mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix: make editable plugin install symlink
This commit is contained in:
@@ -23,12 +23,20 @@ def _write_plugin(path: Path, name: str = "astrbot_plugin_local_demo") -> None:
|
||||
(path / "main.py").write_text("PLUGIN_LOADED = True\n", encoding="utf-8")
|
||||
|
||||
|
||||
def _write_ignored_plugin_files(path: Path) -> None:
|
||||
for ignored_dir in [".git", ".venv", "__pycache__", ".idea", ".vscode", ".zed"]:
|
||||
ignored_path = path / ignored_dir
|
||||
ignored_path.mkdir()
|
||||
(ignored_path / "ignored.txt").write_text("ignored\n", encoding="utf-8")
|
||||
(path / "__pycache__" / "main.pyc").write_bytes(b"ignored")
|
||||
|
||||
|
||||
def _write_astrbot_root(path: Path) -> None:
|
||||
(path / ".astrbot").touch()
|
||||
(path / "data" / "plugins").mkdir(parents=True)
|
||||
|
||||
|
||||
def test_plugin_install_editable_copies_local_plugin(
|
||||
def test_plugin_install_editable_symlinks_local_plugin(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
@@ -47,6 +55,7 @@ def test_plugin_install_editable_copies_local_plugin(
|
||||
|
||||
target = root / "data" / "plugins" / "astrbot_plugin_local_demo"
|
||||
assert result.exit_code == 0
|
||||
assert target.is_symlink()
|
||||
assert (target / "metadata.yaml").exists()
|
||||
assert (target / "main.py").read_text(encoding="utf-8") == "PLUGIN_LOADED = True\n"
|
||||
|
||||
@@ -60,14 +69,21 @@ def test_plugin_install_accepts_local_path_without_editable_flag(
|
||||
root.mkdir()
|
||||
_write_astrbot_root(root)
|
||||
_write_plugin(source)
|
||||
_write_ignored_plugin_files(source)
|
||||
monkeypatch.chdir(root)
|
||||
|
||||
result = CliRunner().invoke(plug, ["install", str(source)])
|
||||
|
||||
target = root / "data" / "plugins" / "astrbot_plugin_local_demo"
|
||||
assert result.exit_code == 0
|
||||
assert (
|
||||
root / "data" / "plugins" / "astrbot_plugin_local_demo" / "metadata.yaml"
|
||||
).exists()
|
||||
assert not target.is_symlink()
|
||||
assert (target / "metadata.yaml").exists()
|
||||
assert not (target / ".git").exists()
|
||||
assert not (target / ".venv").exists()
|
||||
assert not (target / "__pycache__").exists()
|
||||
assert not (target / ".idea").exists()
|
||||
assert not (target / ".vscode").exists()
|
||||
assert not (target / ".zed").exists()
|
||||
|
||||
|
||||
def test_plugin_install_editable_rejects_existing_plugin(
|
||||
|
||||
Reference in New Issue
Block a user