Skip to content

Commit 72f3ae6

Browse files
committed
!squash more
1 parent d4a4957 commit 72f3ae6

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

tests/test_cli.py

+39-11
Original file line numberDiff line numberDiff line change
@@ -262,44 +262,70 @@ def test_sync_broken(
262262

263263
# @pytest.mark.skip("No recreation yet, #366")
264264
def test_broken_submodule(
265-
home_path: pathlib.Path,
265+
user_path: pathlib.Path,
266266
config_path: pathlib.Path,
267267
tmp_path: pathlib.Path,
268268
git_repo: GitSync,
269269
create_git_dummy_repo: DummyRepoProtocol,
270270
) -> None:
271271
runner = CliRunner()
272272

273+
deleted_submodule_repo = create_git_dummy_repo(
274+
repo_name="deleted_submodule_repo", testfile_filename="dummy_file.txt"
275+
)
276+
273277
broken_repo = create_git_dummy_repo(
274278
repo_name="broken_repo", testfile_filename="dummy_file.txt"
275279
)
276280

277281
# Try to recreated gitmodules by hand
278282

279283
# gitmodules_file = pathlib.Path(broken_repo) / ".gitmodules"
280-
# gitmodules_file.write_text(
281-
# """
282-
# [submodule "broken_submodule"]
283-
# path = broken_submodule
284-
# url = ./
284+
# gitmodules_file.write_text(
285+
# """
286+
# [submodule "deleted_submodule_repo"]
287+
# path = deleted_submodule_repo
288+
# url = ../deleted_submodule_repo
285289
# """,
286-
# encoding="utf-8",
287-
# )
290+
# encoding="utf-8",
291+
# )
292+
#
293+
# run(
294+
# [
295+
# "git",
296+
# "submodule",
297+
# "init",
298+
# "--",
299+
# # "deleted_submodule_repo",
300+
# ],
301+
# cwd=str(broken_repo),
302+
# )
288303

289304
run(
290305
[
291306
"git",
292307
"submodule",
293308
"add",
294-
"--quiet",
295-
"--force",
296309
"--",
297-
"./",
310+
"../deleted_submodule_repo",
298311
"broken_submodule",
299312
],
300313
cwd=str(broken_repo),
301314
)
302315

316+
# Assure submodule exists
317+
gitmodules_file = pathlib.Path(broken_repo) / ".gitmodules"
318+
assert gitmodules_file.exists()
319+
assert "../deleted_submodule_repo" in gitmodules_file.read_text()
320+
321+
github_projects = user_path / "github_projects"
322+
broken_repo_checkout = github_projects / "broken_repo"
323+
assert not broken_repo_checkout.exists()
324+
325+
# Delete the submodule dependency
326+
shutil.rmtree(deleted_submodule_repo)
327+
assert not pathlib.Path(deleted_submodule_repo).exists()
328+
303329
with runner.isolated_filesystem(temp_dir=tmp_path):
304330
config = {
305331
"~/github_projects/": {
@@ -320,5 +346,7 @@ def test_broken_submodule(
320346
result = runner.invoke(cli, ["sync", "broken_repo"])
321347
output = "".join(list(result.output))
322348

349+
assert broken_repo_checkout.exists()
350+
323351
assert "No url found for submodule" == output
324352
assert result.exit_code == 1

0 commit comments

Comments
 (0)