|
1 | 1 | import pytest |
2 | 2 | from pathlib import Path |
3 | 3 | import git |
4 | | -from mcp_server_git.server import git_checkout, git_branch |
| 4 | +from mcp_server_git.server import git_checkout, git_branch, git_add |
5 | 5 | import shutil |
6 | 6 |
|
7 | 7 | @pytest.fixture |
@@ -68,3 +68,26 @@ def test_git_branch_not_contains(test_repository): |
68 | 68 | result = git_branch(test_repository, "local", not_contains=commit.hexsha) |
69 | 69 | assert "another-feature-branch" not in result |
70 | 70 | assert "master" in result |
| 71 | + |
| 72 | +def test_git_add_all_files(test_repository): |
| 73 | + file_path = Path(test_repository.working_dir) / "all_file.txt" |
| 74 | + file_path.write_text("adding all") |
| 75 | + |
| 76 | + result = git_add(test_repository, ["."]) |
| 77 | + |
| 78 | + staged_files = [item.a_path for item in test_repository.index.diff("HEAD")] |
| 79 | + assert "all_file.txt" in staged_files |
| 80 | + assert result == "Files staged successfully" |
| 81 | + |
| 82 | +def test_git_add_specific_files(test_repository): |
| 83 | + file1 = Path(test_repository.working_dir) / "file1.txt" |
| 84 | + file2 = Path(test_repository.working_dir) / "file2.txt" |
| 85 | + file1.write_text("file 1 content") |
| 86 | + file2.write_text("file 2 content") |
| 87 | + |
| 88 | + result = git_add(test_repository, ["file1.txt"]) |
| 89 | + |
| 90 | + staged_files = [item.a_path for item in test_repository.index.diff("HEAD")] |
| 91 | + assert "file1.txt" in staged_files |
| 92 | + assert "file2.txt" not in staged_files |
| 93 | + assert result == "Files staged successfully" |
0 commit comments