22 lines
741 B
Python
22 lines
741 B
Python
import pytest
|
|
import subprocess
|
|
import os
|
|
import tempfile
|
|
from git_commit_ai.core.git_handler import get_staged_changes, get_commit_history
|
|
|
|
def test_get_commit_history_empty():
|
|
"""Test get commit history when no commits exist."""
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
os.chdir(tmpdir)
|
|
subprocess.run(['git', 'init'], capture_output=True)
|
|
history = get_commit_history()
|
|
assert history == []
|
|
|
|
def test_get_staged_changes_empty_repo():
|
|
"""Test get staged changes in empty repository."""
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
os.chdir(tmpdir)
|
|
subprocess.run(['git', 'init'], capture_output=True)
|
|
changes = get_staged_changes()
|
|
assert changes == []
|