Skip to content

test(cli): cover docs-only, aliases, stack hints, index failure, watch loop (closes #103)#109

Merged
wesleysimplicio merged 1 commit into
mainfrom
claude/issue-103-cli-coverage
Jun 2, 2026
Merged

test(cli): cover docs-only, aliases, stack hints, index failure, watch loop (closes #103)#109
wesleysimplicio merged 1 commit into
mainfrom
claude/issue-103-cli-coverage

Conversation

@wesleysimplicio
Copy link
Copy Markdown
Owner

Resumo

Fecha #103. Adiciona testes para os 5 caminhos documentados da CLI Python que não tinham assertion.

Mudanças

  • tests/python/test_cli_coverage.py novo, 6 testes (5 cenários + 1 boundary do watch):
    • StackAndProductHintInjectionTest--stack/--product-name fluem para product.stack/product.name quando .starter-meta.json está ausente.
    • JsonOnlyAndChangedOnlyAliasesTest--json-only mantém docs desligado; --changed-only força incremental.
    • DocsOnlyShortCircuitTest--docs-only no index renderiza Markdown sem reescrever o JSON.
    • IndexFailureBoundaryTestmock.patch em _run_index lança exception → CLI retorna exit 1 + JSON status="failed" com error.
    • WatchLoopExitsOnInterruptTest_watch bounded test (patch em time.sleep lançando KeyboardInterrupt) garante saída limpa.

Cada teste asserta sobre output observável (conteúdo do artifact ou JSON), não call counts internos.

Validação

Item Resultado
test_cli_coverage ✅ 6 pass
Suite Python completa ✅ 36 pass (1 falha pré-existente do container: git commit no fixture pelo signing server; idêntica ao baseline em main)

Refs #103.

https://claude.ai/code/session_01JdmemqddwFnvbceWyuDE8m


Generated by Claude Code

…h loop

Closes #103.

`tests/python/test_cli.py` did not exercise five documented public CLI
behaviors. Add a dedicated `tests/python/test_cli_coverage.py` module covering
each:

- `StackAndProductHintInjectionTest` asserts `--stack` / `--product-name`
  flow into `product.stack` / `product.name` in the emitted project-map when
  `.starter-meta.json` is absent.
- `JsonOnlyAndChangedOnlyAliasesTest` covers the orchestrator-facing
  compatibility aliases — `--json-only` keeps docs disabled, `--changed-only`
  forces incremental refresh.
- `DocsOnlyShortCircuitTest` confirms `--docs-only` on `index` renders the
  Markdown wiki without rewriting the JSON payload.
- `IndexFailureBoundaryTest` patches `_run_index` to throw and asserts the
  `index` CLI returns exit 1 with a stable `status="failed"` JSON payload
  carrying the underlying error message.
- `WatchLoopExitsOnInterruptTest` is a bounded test for `_watch`: it
  monkey-patches `time.sleep` to raise `KeyboardInterrupt` on the first tick
  so the loop exits via its documented branch without crashing.

Each test asserts observable artifact contents or the JSON result, not
internal call counts.

https://claude.ai/code/session_01JdmemqddwFnvbceWyuDE8m
@wesleysimplicio wesleysimplicio marked this pull request as ready for review June 2, 2026 13:27
Copilot AI review requested due to automatic review settings June 2, 2026 13:27
@wesleysimplicio wesleysimplicio merged commit 0401523 into main Jun 2, 2026
30 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fecha a lacuna de cobertura dos caminhos “documentados” da CLI Python (Issue #103), adicionando uma nova suíte de testes que exercita flags/rotas que eram parte do contrato público, mas não tinham assertions de saída observável.

Changes:

  • Adiciona tests/python/test_cli_coverage.py com cenários para --docs-only, aliases --json-only/--changed-only, injeção de hints --stack/--product-name, boundary de falha do index, e um teste bounded do loop de _watch.
  • Os testes focam em efeitos observáveis (arquivos gerados e/ou payload JSON emitido), e não em contagem de chamadas internas.

Comment on lines +83 to +86
def test_json_only_keeps_docs_disabled(self) -> None:
code, _, _ = _run([
"index", str(self.dir), "--json", "--json-only",
])
Comment on lines +118 to +126
project_map_path = self.dir / ".simplicio" / "project-map.json"
before = project_map_path.read_text()
code, _, _ = _run([
"index", str(self.dir), "--docs-only", "--json",
])
self.assertEqual(code, 0)
after = project_map_path.read_text()
# JSON payload is not rewritten by --docs-only.
self.assertEqual(before, after)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants