Initial upload: Local AI Commit Reviewer CLI with CI/CD workflow
This commit is contained in:
43
tests/unit/test_git.py
Normal file
43
tests/unit/test_git.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
from src.git.git import GitRepo, FileChange
|
||||
|
||||
|
||||
class TestGitRepo:
|
||||
def test_get_file_language(self):
|
||||
repo = GitRepo(Path.cwd())
|
||||
assert repo.get_file_language("test.py") == "python"
|
||||
assert repo.get_file_language("test.js") == "javascript"
|
||||
assert repo.get_file_language("test.go") == "go"
|
||||
assert repo.get_file_language("test.rs") == "rust"
|
||||
assert repo.get_file_language("test.unknown") == "unknown"
|
||||
|
||||
def test_get_diff_stats(self):
|
||||
repo = GitRepo(Path.cwd())
|
||||
diff = """diff --git a/test.py b/test.py
|
||||
--- a/test.py
|
||||
+++ b/test.py
|
||||
@@ -1,3 +1,4 @@
|
||||
def hello():
|
||||
+ print("hello")
|
||||
return True
|
||||
- return False
|
||||
"""
|
||||
additions, deletions = repo.get_diff_stats(diff)
|
||||
assert additions == 1
|
||||
assert deletions == 1
|
||||
|
||||
|
||||
class TestFileChange:
|
||||
def test_file_change_creation(self):
|
||||
change = FileChange(
|
||||
filename="test.py",
|
||||
status="M",
|
||||
diff="diff content"
|
||||
)
|
||||
assert change.filename == "test.py"
|
||||
assert change.status == "M"
|
||||
assert change.diff == "diff content"
|
||||
Reference in New Issue
Block a user