Initial upload: Git Commit AI - privacy-first CLI for generating commit messages with local LLM
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
65
git_commit_ai/tests/test_cli.py
Normal file
65
git_commit_ai/tests/test_cli.py
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
"""Tests for the CLI module."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
import click
|
||||||
|
from click.testing import CliRunner
|
||||||
|
|
||||||
|
from git_commit_ai.cli.cli import main
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIBasic:
|
||||||
|
"""Basic CLI tests."""
|
||||||
|
|
||||||
|
def test_main_help(self):
|
||||||
|
"""Test main command help."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["--help"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "Git Commit AI" in result.output
|
||||||
|
assert "generate" in result.output
|
||||||
|
assert "status" in result.output
|
||||||
|
|
||||||
|
def test_generate_help(self):
|
||||||
|
"""Test generate command help."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["generate", "--help"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "conventional" in result.output
|
||||||
|
assert "model" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIValidation:
|
||||||
|
"""CLI validation tests."""
|
||||||
|
|
||||||
|
def test_validate_valid_message(self):
|
||||||
|
"""Test validating a valid conventional commit message."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["validate", "feat(auth): add login"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "Valid" in result.output
|
||||||
|
|
||||||
|
def test_validate_invalid_message(self):
|
||||||
|
"""Test validating an invalid commit message."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["validate", "just a random message"])
|
||||||
|
assert result.exit_code == 1
|
||||||
|
assert "Invalid" in result.output
|
||||||
|
|
||||||
|
def test_validate_empty_message(self):
|
||||||
|
"""Test validating an empty commit message."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["validate", ""])
|
||||||
|
assert result.exit_code == 1
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIAutoFix:
|
||||||
|
"""CLI auto-fix tests."""
|
||||||
|
|
||||||
|
def test_validate_auto_fix(self):
|
||||||
|
"""Test auto-fix suggestion."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(main, ["validate", "add login feature", "--auto-fix"])
|
||||||
|
assert result.exit_code == 1
|
||||||
|
assert "Suggested fix" in result.output
|
||||||
Reference in New Issue
Block a user