Skip to content

Commit 6df2727

Browse files
jayzhou2309cliffhall
authored andcommitted
test(git): cover git_show with blob and tree object specs
Signed-off-by: cliffhall <[email protected]>
1 parent 571e2b3 commit 6df2727

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎src/git/tests/test_server.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,28 @@ def test_git_show_initial_commit(test_repository):
293293
assert "initial commit" in result
294294
assert "test.txt" in result
295295

296+
def test_git_show_blob_object_spec(test_repository):
297+
file_path = Path(test_repository.working_dir) / "logic" / "infos.py"
298+
file_path.parent.mkdir()
299+
file_path.write_text("print('infos')\n")
300+
test_repository.index.add(["logic/infos.py"])
301+
test_repository.index.commit("add infos")
302+
303+
result = git_show(test_repository, "HEAD:logic/infos.py")
304+
305+
assert result == "print('infos')\n"
306+
307+
def test_git_show_tree_object_spec(test_repository):
308+
file_path = Path(test_repository.working_dir) / "logic" / "infos.py"
309+
file_path.parent.mkdir()
310+
file_path.write_text("print('infos')\n")
311+
test_repository.index.add(["logic/infos.py"])
312+
test_repository.index.commit("add infos")
313+
314+
result = git_show(test_repository, "HEAD:")
315+
316+
assert result == "logic/\ntest.txt"
317+
296318

297319
# Tests for validate_repo_path (repository scoping security fix)
298320

0 commit comments

Comments
 (0)