From c521471d44e2d62b3907d3de683643859865abd5 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sat, 31 Jan 2026 13:13:15 +0000 Subject: [PATCH] Initial upload with CI/CD workflow --- shellhist/tests/test_cli.py | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 shellhist/tests/test_cli.py diff --git a/shellhist/tests/test_cli.py b/shellhist/tests/test_cli.py new file mode 100644 index 0000000..5b230b6 --- /dev/null +++ b/shellhist/tests/test_cli.py @@ -0,0 +1,82 @@ +"""Tests for CLI commands.""" + +from click.testing import CliRunner + +from shellhist.cli import main + + +class TestCLI: + """Test CLI main entry point.""" + + def test_version(self): + """Test version option.""" + runner = CliRunner() + result = runner.invoke(main, ["--version"]) + + assert result.exit_code == 0 + assert "shellhist" in result.output.lower() + + def test_help(self): + """Test help option.""" + runner = CliRunner() + result = runner.invoke(main, ["--help"]) + + assert result.exit_code == 0 + assert "search" in result.output + assert "patterns" in result.output + + def test_search_command_exists(self): + """Test search subcommand exists.""" + runner = CliRunner() + result = runner.invoke(main, ["search", "--help"]) + + assert result.exit_code == 0 + + def test_patterns_command_exists(self): + """Test patterns subcommand exists.""" + runner = CliRunner() + result = runner.invoke(main, ["patterns", "--help"]) + + assert result.exit_code == 0 + + def test_suggest_aliases_command_exists(self): + """Test suggest-aliases subcommand exists.""" + runner = CliRunner() + result = runner.invoke(main, ["suggest-aliases", "--help"]) + + assert result.exit_code == 0 + + def test_analyze_time_command_exists(self): + """Test analyze-time subcommand exists.""" + runner = CliRunner() + result = runner.invoke(main, ["analyze-time", "--help"]) + + assert result.exit_code == 0 + + def test_export_script_command_exists(self): + """Test export-script subcommand exists.""" + runner = CliRunner() + result = runner.invoke(main, ["export-script", "--help"]) + + assert result.exit_code == 0 + + def test_search_with_missing_history(self): + """Test search with non-existent history file.""" + runner = CliRunner() + result = runner.invoke( + main, + ["search", "test", "--history", "/nonexistent/file"] + ) + + assert result.exit_code != 0 + assert "not found" in result.output.lower() or "error" in result.output.lower() + + def test_patterns_with_missing_history(self): + """Test patterns with non-existent history file.""" + runner = CliRunner() + result = runner.invoke( + main, + ["patterns", "--history", "/nonexistent/file"] + ) + + assert result.exit_code != 0