Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/maxed_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def smoke(

if not connectors:
if as_json:
typer.echo(json.dumps({"results": []}))
_emit_json({"ok": True, "results": []})
else:
typer.secho("No connectors defined in config.", fg=typer.colors.YELLOW)
return
Expand Down Expand Up @@ -359,7 +359,7 @@ def smoke(
)

if as_json:
typer.echo(json.dumps({"results": results}, indent=2))
_emit_json({"ok": failures == 0, "results": results})
else:
for r in results:
mark = "PASS" if r["ok"] else "FAIL"
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def test_smoke_json(tmp_path: Path) -> None:
cfg = _yaml(tmp_path / "c.yaml", VALID_CONFIG)
result = runner.invoke(app, ["smoke", str(cfg), "--json"])
assert result.exit_code == 0
assert result.stdout.startswith('{\n "ok": true,\n')
payload = json.loads(result.stdout)
assert payload["ok"] is True
assert len(payload["results"]) == 2
assert all(r["ok"] for r in payload["results"])

Expand All @@ -142,6 +144,15 @@ def test_smoke_no_connectors(tmp_path: Path) -> None:
assert "No connectors" in result.stdout


def test_smoke_json_no_connectors(tmp_path: Path) -> None:
no_conn = {k: v for k, v in VALID_CONFIG.items() if k != "connectors"}
cfg = _yaml(tmp_path / "c.yaml", no_conn)
result = runner.invoke(app, ["smoke", str(cfg), "--json"])
assert result.exit_code == 0
assert result.stdout == '{\n "ok": true,\n "results": []\n}\n'
assert json.loads(result.stdout) == {"ok": True, "results": []}


def test_schema_default_is_workpaper() -> None:
result = runner.invoke(app, ["schema"])
assert result.exit_code == 0
Expand Down