Skip to content

Commit f79ce06

Browse files
committed
tests/sync(fix[test_hg]): Use private remote in pull-failure test
why: test_update_repo_pull_failure_returns_sync_result deleted the session-scoped hg_remote_repo, breaking all subsequent tests that depend on it (e.g. tests/url/test_hg.py::test_hg_url). what: - Use create_hg_remote_repo factory to create a disposable remote - Matches the pattern used by the equivalent git test
1 parent 21965b0 commit f79ce06

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

tests/sync/test_hg.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44

55
import pathlib
66
import shutil
7+
import typing as t
78

89
import pytest
910

1011
from libvcs import exc
1112
from libvcs._internal.run import run
1213
from libvcs._internal.shortcuts import create_project
14+
from libvcs.pytest_plugin import hg_remote_repo_single_commit_post_init
1315
from libvcs.sync.base import SyncResult
1416
from libvcs.sync.hg import HgSync
1517

18+
if t.TYPE_CHECKING:
19+
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
20+
1621
if not shutil.which("hg"):
1722
pytestmark = pytest.mark.skip(reason="hg is not available")
1823

@@ -107,23 +112,23 @@ def test_vulnerability_2022_03_12_command_injection(
107112

108113

109114
def test_update_repo_pull_failure_returns_sync_result(
110-
tmp_path: pathlib.Path,
111115
projects_path: pathlib.Path,
112-
hg_remote_repo: pathlib.Path,
116+
create_hg_remote_repo: CreateRepoPytestFixtureFn,
113117
) -> None:
114118
"""Test that a deleted remote in update_repo() returns SyncResult with error."""
115119
repo_name = "my_hg_error_project"
120+
hg_remote = create_hg_remote_repo(
121+
remote_repo_post_init=hg_remote_repo_single_commit_post_init,
122+
)
116123

117124
hg_repo = HgSync(
118-
url=f"file://{hg_remote_repo}",
125+
url=f"file://{hg_remote}",
119126
path=projects_path / repo_name,
120127
)
121128

122-
# First update_repo clones since .hg doesn't exist yet
123129
hg_repo.update_repo()
124130

125-
# Delete the remote to cause a pull failure
126-
shutil.rmtree(hg_remote_repo)
131+
shutil.rmtree(hg_remote)
127132

128133
result = hg_repo.update_repo()
129134

0 commit comments

Comments
 (0)