fix: align git mount implementation with spec
- _checkout_branch now returns bool and falls back gracefully on failure - Glob warning message includes matched file count - Fix database model comment to reference remote_url - Update tests for new branch checkout behavior All 51 tests pass
This commit is contained in:
@@ -91,23 +91,22 @@ class TestCheckoutBranch:
|
||||
assert result == "feature"
|
||||
|
||||
def test_checkout_nonexistent_branch(self, tmp_path: Path) -> None:
|
||||
"""Test checking out a non-existent branch raises error."""
|
||||
"""Test checking out a non-existent branch returns False."""
|
||||
os.system(f"cd {tmp_path} && git init && git config user.email 'test@test.com' && git config user.name 'Test'")
|
||||
(tmp_path / "file.txt").write_text("content")
|
||||
os.system(f"cd {tmp_path} && git add . && git commit -m 'initial'")
|
||||
|
||||
with pytest.raises(RuntimeError, match="Failed to checkout branch"):
|
||||
_checkout_branch(str(tmp_path), "nonexistent")
|
||||
result = _checkout_branch(str(tmp_path), "nonexistent")
|
||||
assert result is False
|
||||
|
||||
|
||||
class TestResolveSingleGitMount:
|
||||
"""Unit tests for resolving a single git mount."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resolve_missing_repo(self, db_session) -> None:
|
||||
"""Test that missing repo returns empty list."""
|
||||
async def test_resolve_missing_remote_url(self, db_session) -> None:
|
||||
"""Test that missing remote_url returns empty list."""
|
||||
git_mount = {
|
||||
"repo_id": "12345678-1234-1234-1234-123456789abc",
|
||||
"source_path": ".",
|
||||
"target_path": "/app",
|
||||
}
|
||||
@@ -119,21 +118,9 @@ class TestResolveSingleGitMount:
|
||||
async def test_resolve_missing_target_path(self, db_session) -> None:
|
||||
"""Test that missing target path returns empty list."""
|
||||
git_mount = {
|
||||
"repo_id": "12345678-1234-1234-1234-123456789abc",
|
||||
"remote_url": "https://github.com/user/repo.git",
|
||||
"source_path": ".",
|
||||
}
|
||||
|
||||
result = await _resolve_single_git_mount(db_session, git_mount)
|
||||
assert result == []
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resolve_invalid_repo_id(self, db_session) -> None:
|
||||
"""Test that invalid repo_id returns empty list."""
|
||||
git_mount = {
|
||||
"repo_id": "not-a-uuid",
|
||||
"source_path": ".",
|
||||
"target_path": "/app",
|
||||
}
|
||||
|
||||
result = await _resolve_single_git_mount(db_session, git_mount)
|
||||
assert result == []
|
||||
|
||||
Reference in New Issue
Block a user