Skip to content

Commit d7f8a3b

Browse files
committed
Test ManagedGitRepo with str and Repo
1 parent 70a098d commit d7f8a3b

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

tests/utils/test_git.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,16 @@ def test_managed_git_repo_remote_url_property(tmp_path: Path):
207207
assert repo.remote_url == "https://github.com/my-org/my-repo.git"
208208

209209

210-
def test_managed_git_repo_slug_property(tmp_path: Path):
211-
"""Test the slug property of ManagedGitRepo."""
212-
remote_url = "https://github.com/my-org/my-repo.git"
213-
repo = ManagedGitRepo(remote_url, tmp_path)
210+
@pytest.mark.parametrize(
211+
"repo_input",
212+
[
213+
"https://github.com/my-org/my-repo.git",
214+
Repo("gh://my-org/my-repo"),
215+
],
216+
)
217+
def test_managed_git_repo_slug_property(tmp_path: Path, repo_input):
218+
"""Test the slug property of ManagedGitRepo for str and Repo inputs."""
219+
repo = ManagedGitRepo(repo_input, tmp_path)
214220
# The slug should be a filesystem-safe version of the canonical URL
215221
expected_slug = "https___github_com_my_org_my_repo_git"
216222
assert repo.slug == expected_slug
@@ -224,6 +230,13 @@ def test_managed_git_repo_permanent_root_property(tmp_path: Path):
224230
assert repo.permanent_root == permanent_root
225231

226232

233+
def test_managed_git_repo_invalid_repo_type(tmp_path: Path):
234+
"""ManagedGitRepo should reject unsupported repo types with TypeError."""
235+
236+
with pytest.raises(TypeError, match="remote_url must be a string or Repo instance"):
237+
ManagedGitRepo(123, tmp_path) # type: ignore[arg-type]
238+
239+
227240
async def test_fetch_updates_success(
228241
tmp_path: Path, mock_execute_git: AsyncMock, monkeypatch
229242
):

0 commit comments

Comments
 (0)