Skip to content

Commit

Permalink
!squash more
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Sep 25, 2022
1 parent d4a4957 commit 72f3ae6
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,44 +262,70 @@ def test_sync_broken(

# @pytest.mark.skip("No recreation yet, #366")
def test_broken_submodule(
home_path: pathlib.Path,
user_path: pathlib.Path,
config_path: pathlib.Path,
tmp_path: pathlib.Path,
git_repo: GitSync,
create_git_dummy_repo: DummyRepoProtocol,
) -> None:
runner = CliRunner()

deleted_submodule_repo = create_git_dummy_repo(
repo_name="deleted_submodule_repo", testfile_filename="dummy_file.txt"
)

broken_repo = create_git_dummy_repo(
repo_name="broken_repo", testfile_filename="dummy_file.txt"
)

# Try to recreated gitmodules by hand

# gitmodules_file = pathlib.Path(broken_repo) / ".gitmodules"
# gitmodules_file.write_text(
# """
# [submodule "broken_submodule"]
# path = broken_submodule
# url = ./
# gitmodules_file.write_text(
# """
# [submodule "deleted_submodule_repo"]
# path = deleted_submodule_repo
# url = ../deleted_submodule_repo
# """,
# encoding="utf-8",
# )
# encoding="utf-8",
# )
#
# run(
# [
# "git",
# "submodule",
# "init",
# "--",
# # "deleted_submodule_repo",
# ],
# cwd=str(broken_repo),
# )

run(
[
"git",
"submodule",
"add",
"--quiet",
"--force",
"--",
"./",
"../deleted_submodule_repo",
"broken_submodule",
],
cwd=str(broken_repo),
)

# Assure submodule exists
gitmodules_file = pathlib.Path(broken_repo) / ".gitmodules"
assert gitmodules_file.exists()
assert "../deleted_submodule_repo" in gitmodules_file.read_text()

github_projects = user_path / "github_projects"
broken_repo_checkout = github_projects / "broken_repo"
assert not broken_repo_checkout.exists()

# Delete the submodule dependency
shutil.rmtree(deleted_submodule_repo)
assert not pathlib.Path(deleted_submodule_repo).exists()

with runner.isolated_filesystem(temp_dir=tmp_path):
config = {
"~/github_projects/": {
Expand All @@ -320,5 +346,7 @@ def test_broken_submodule(
result = runner.invoke(cli, ["sync", "broken_repo"])
output = "".join(list(result.output))

assert broken_repo_checkout.exists()

assert "No url found for submodule" == output
assert result.exit_code == 1

0 comments on commit 72f3ae6

Please sign in to comment.