Skip to content

Commit 1d81975

Browse files
committed
test(git): Test update_repo(set_remotes=True)
1 parent a47aea3 commit 1d81975

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/test_git.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,73 @@ def test_remotes(
299299
) == git_repo.remote(expected_remote_name)
300300

301301

302+
@pytest.mark.parametrize(
303+
# Postpone evaluation of options so fixture variables can interpolate
304+
"constructor,lazy_constructor_options,lazy_remote_dict,lazy_remote_expected",
305+
[
306+
[
307+
GitRepo,
308+
lambda git_remote, repos_path, repo_name, **kwargs: {
309+
"url": f"file://{git_remote}",
310+
"repo_dir": repos_path / repo_name,
311+
"remotes": {
312+
"origin": f"file://{git_remote}",
313+
},
314+
},
315+
lambda git_remote, **kwargs: {
316+
"second_remote": f"file://{git_remote}",
317+
},
318+
lambda git_remote, **kwargs: {
319+
"origin": f"file://{git_remote}",
320+
"second_remote": f"file://{git_remote}",
321+
},
322+
],
323+
[
324+
GitRepo,
325+
lambda git_remote, repos_path, repo_name, **kwargs: {
326+
"url": f"file://{git_remote}",
327+
"repo_dir": repos_path / repo_name,
328+
"remotes": {
329+
"origin": f"file://{git_remote}",
330+
},
331+
},
332+
lambda git_remote, **kwargs: {
333+
"origin": "https://github.com/vcs-python/libvcs",
334+
},
335+
lambda git_remote, **kwargs: {
336+
"origin": "https://github.com/vcs-python/libvcs",
337+
},
338+
],
339+
],
340+
)
341+
def test_remotes_update_repo(
342+
repos_path: pathlib.Path,
343+
git_remote: pathlib.Path,
344+
constructor: RepoTestFactory,
345+
lazy_constructor_options: RepoTestFactoryLazyKwargs,
346+
lazy_remote_dict: RepoTestFactoryRemotesLazyExpected,
347+
lazy_remote_expected: RepoTestFactoryRemotesLazyExpected,
348+
):
349+
repo_name = "myrepo"
350+
remote_name = "myremote"
351+
remote_url = "https://localhost/my/git/repo.git"
352+
353+
git_repo: GitRepo = constructor(**lazy_constructor_options(**locals()))
354+
git_repo.obtain()
355+
356+
git_repo._remotes = lazy_remote_dict(**locals())
357+
git_repo.update_repo(set_remotes=True)
358+
359+
expected = lazy_remote_expected(**locals())
360+
assert len(expected.keys()) > 0
361+
for expected_remote_name, expected_remote_url in expected.items():
362+
assert (
363+
expected_remote_name,
364+
expected_remote_url,
365+
expected_remote_url,
366+
) == git_repo.remote(expected_remote_name)
367+
368+
302369
def test_git_get_url_and_rev_from_pip_url():
303370
pip_url = "git+ssh://git@bitbucket.example.com:7999/PROJ/repo.git"
304371

0 commit comments

Comments
 (0)