|
1 | | -"""Tests for the --version CLI flag.""" |
| 1 | +"""Tests for CLI version reporting.""" |
2 | 2 |
|
| 3 | +import json |
3 | 4 | from unittest.mock import patch |
4 | 5 |
|
5 | 6 | from typer.testing import CliRunner |
@@ -33,3 +34,46 @@ def test_version_flag_takes_precedence_over_subcommand(self): |
33 | 34 | result = runner.invoke(app, ["--version", "init"]) |
34 | 35 | assert result.exit_code == 0 |
35 | 36 | assert "specify 0.7.2" in result.output |
| 37 | + |
| 38 | + |
| 39 | +class TestVersionCommand: |
| 40 | + """Test the `specify version` subcommand.""" |
| 41 | + |
| 42 | + def test_version_features_text(self): |
| 43 | + """specify version --features prints local capability flags.""" |
| 44 | + with patch("specify_cli.get_speckit_version", return_value="1.2.3"): |
| 45 | + result = runner.invoke(app, ["version", "--features"]) |
| 46 | + |
| 47 | + assert result.exit_code == 0 |
| 48 | + assert "Spec Kit CLI: 1.2.3" in result.output |
| 49 | + assert "Features:" in result.output |
| 50 | + assert "- controlled multi install integrations: yes" in result.output |
| 51 | + assert "- integration use command: yes" in result.output |
| 52 | + assert "- self check command: yes" in result.output |
| 53 | + |
| 54 | + def test_version_features_json(self): |
| 55 | + """specify version --features --json prints machine-readable capabilities.""" |
| 56 | + with patch("specify_cli.get_speckit_version", return_value="1.2.3"): |
| 57 | + result = runner.invoke(app, ["version", "--features", "--json"]) |
| 58 | + |
| 59 | + assert result.exit_code == 0 |
| 60 | + payload = json.loads(result.output) |
| 61 | + assert payload == { |
| 62 | + "version": "1.2.3", |
| 63 | + "features": { |
| 64 | + "controlled_multi_install_integrations": True, |
| 65 | + "integration_use_command": True, |
| 66 | + "multi_install_safe_registry_metadata": True, |
| 67 | + "integration_upgrade_command": True, |
| 68 | + "self_check_command": True, |
| 69 | + "workflow_catalog": True, |
| 70 | + "bundled_templates": True, |
| 71 | + }, |
| 72 | + } |
| 73 | + |
| 74 | + def test_version_json_requires_features(self): |
| 75 | + """specify version --json is rejected until a JSON surface exists.""" |
| 76 | + result = runner.invoke(app, ["version", "--json"]) |
| 77 | + |
| 78 | + assert result.exit_code != 0 |
| 79 | + assert "--json requires --features" in result.output |
0 commit comments