* feat(infra): backend cookiecutter template with fastapi tortoise * feat(infra): cli cookiecutter template with typer entry point * feat(infra): fullstack cookiecutter template with sveltekit frontend * test(infra): cookiecutter template tests and render fixes * style(infra): ruff cleanup for cookiecutter template tests * style(infra): ruff format cookiecutter template tests * fix(infra): handle use_db no use_auth no in cookiecutter --------- Co-authored-by: opencode-agent <agent@opencode.local>
34 lines
No EOL
1 KiB
Python
34 lines
No EOL
1 KiB
Python
"""CLI tests — invoke the Typer app via CliRunner."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from {{ cookiecutter.project_name }}.cli import app
|
|
|
|
|
|
def test_hello_default(runner: CliRunner) -> None:
|
|
"""``hello`` with no arg greets the world."""
|
|
result = runner.invoke(app, ["hello"])
|
|
assert result.exit_code == 0
|
|
assert "Hello, world!" in result.stdout
|
|
|
|
|
|
def test_hello_name(runner: CliRunner) -> None:
|
|
"""``hello <name>`` greets the given name."""
|
|
result = runner.invoke(app, ["hello", "Alice"])
|
|
assert result.exit_code == 0
|
|
assert "Hello, Alice!" in result.stdout
|
|
|
|
|
|
def test_version(runner: CliRunner) -> None:
|
|
"""``version`` prints the package version."""
|
|
result = runner.invoke(app, ["version"])
|
|
assert result.exit_code == 0
|
|
assert "0.1.0" in result.stdout
|
|
|
|
|
|
def test_no_args_shows_help(runner: CliRunner) -> None:
|
|
"""No args → help (no_args_is_help=True)."""
|
|
result = runner.invoke(app, [])
|
|
assert result.exit_code != 0 or "Usage" in result.stdout |