From 49848c64735e723b0526c435a8d70a6eac63357f Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 22 Mar 2026 18:15:43 +0000 Subject: [PATCH] Initial upload: shell-history-semantic-search v0.1.0 --- tests/test_cli.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/test_cli.py diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..3ea1b9d --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,71 @@ +import pytest +from click.testing import CliRunner + +from shell_history_search.cli import cli + + +class TestCLI: + def test_cli_help(self): + runner = CliRunner() + result = runner.invoke(cli, ["--help"]) + assert result.exit_code == 0 + assert "Usage:" in result.output + assert "--help" in result.output + + def test_index_command(self): + runner = CliRunner() + result = runner.invoke(cli, ["index"]) + assert result.exit_code == 0 + assert "Indexing" in result.output or "Indexed" in result.output + + def test_stats_command(self): + runner = CliRunner() + result = runner.invoke(cli, ["stats"]) + assert result.exit_code == 0 + assert "Statistics" in result.output or "total" in result.output.lower() + + def test_search_command(self): + runner = CliRunner() + result = runner.invoke(cli, ["search", "git commit"]) + assert result.exit_code == 0 + + def test_search_with_limit(self): + runner = CliRunner() + result = runner.invoke(cli, ["search", "git", "--limit", "5"]) + assert result.exit_code == 0 + + def test_search_with_shell_filter(self): + runner = CliRunner() + result = runner.invoke(cli, ["search", "git", "--shell", "bash"]) + assert result.exit_code == 0 + + def test_search_with_json_output(self): + runner = CliRunner() + result = runner.invoke(cli, ["search", "git", "--json"]) + assert result.exit_code == 0 + import json + try: + data = json.loads(result.output) + assert isinstance(data, list) + except json.JSONDecodeError: + pass + + def test_index_with_shell_filter(self): + runner = CliRunner() + result = runner.invoke(cli, ["index", "--shell", "bash"]) + assert result.exit_code == 0 + + def test_index_with_invalid_shell(self): + runner = CliRunner() + result = runner.invoke(cli, ["index", "--shell", "csh"]) + assert result.exit_code != 0 + + def test_clear_command_no_confirm(self): + runner = CliRunner() + result = runner.invoke(cli, ["clear"], input="n\n") + assert result.exit_code != 0 + + def test_verbose_flag(self): + runner = CliRunner() + result = runner.invoke(cli, ["-v", "stats"]) + assert result.exit_code == 0 \ No newline at end of file