mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
add init command
This commit is contained in:
parent
754cb7a091
commit
cde1d0f87f
7 changed files with 806 additions and 0 deletions
59
cli/test/test_init.py
Normal file
59
cli/test/test_init.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
from click.testing import CliRunner
|
||||
|
||||
from planoai.init_cmd import init
|
||||
|
||||
|
||||
def test_init_clean_writes_empty_config(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(init, ["--clean"])
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
config_path = tmp_path / "config.yaml"
|
||||
assert config_path.exists()
|
||||
assert config_path.read_text(encoding="utf-8") == "\n"
|
||||
|
||||
|
||||
def test_init_template_builtin_writes_config_and_env(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
init, ["--template", "use_cases/claude_code_router", "--yes"]
|
||||
)
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
|
||||
config_path = tmp_path / "config.yaml"
|
||||
assert config_path.exists()
|
||||
config_text = config_path.read_text(encoding="utf-8")
|
||||
assert "llm_providers:" in config_text
|
||||
|
||||
env_path = tmp_path / ".env"
|
||||
assert env_path.exists()
|
||||
env_text = env_path.read_text(encoding="utf-8")
|
||||
assert "OPENAI_API_KEY=" in env_text
|
||||
assert "ANTHROPIC_API_KEY=" in env_text
|
||||
|
||||
|
||||
def test_init_refuses_overwrite_without_force(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
(tmp_path / "config.yaml").write_text("hello", encoding="utf-8")
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(init, ["--clean"])
|
||||
|
||||
assert result.exit_code != 0
|
||||
assert "Refusing to overwrite" in result.output
|
||||
|
||||
|
||||
def test_init_force_overwrites(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
(tmp_path / "config.yaml").write_text("hello", encoding="utf-8")
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(init, ["--clean", "--force"])
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
assert (tmp_path / "config.yaml").read_text(encoding="utf-8") == "\n"
|
||||
Loading…
Add table
Add a link
Reference in a new issue