Skip to content

Commit 3a6b68b

Browse files
committed
tests/cli(fmt): capture workspace root normalization gap
1 parent 4ca8159 commit 3a6b68b

1 file changed

Lines changed: 55 additions & 2 deletions

File tree

tests/cli/test_fmt.py

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import logging
6+
import pathlib
67
import typing as t
78

89
import pytest
@@ -11,8 +12,6 @@
1112
from vcspull.cli.fmt import format_config, format_config_file, normalize_repo_config
1213

1314
if t.TYPE_CHECKING:
14-
import pathlib
15-
1615
from _pytest.logging import LogCaptureFixture
1716

1817

@@ -65,6 +64,60 @@ def test_both_url_and_repo(self) -> None:
6564
class TestFormatConfig:
6665
"""Test configuration formatting."""
6766

67+
@pytest.mark.xfail(
68+
reason="Workspace root normalization not yet implemented in formatter.",
69+
strict=True,
70+
)
71+
@pytest.mark.parametrize(
72+
"config, expected_roots",
73+
[
74+
pytest.param(
75+
{
76+
"~/study/c": {
77+
"cpython": {"repo": "git+https://github.com/python/cpython.git"},
78+
},
79+
"~/study/c/": {
80+
"tmux": {"repo": "git+https://github.com/tmux/tmux.git"},
81+
},
82+
},
83+
["~/study/c/"],
84+
id="tilde-mixed-trailing-slash",
85+
),
86+
pytest.param(
87+
{
88+
str(pathlib.Path.home() / "study" / "c"): {
89+
"cpython": {"repo": "git+https://github.com/python/cpython.git"},
90+
},
91+
"~/study/c/": {
92+
"tmux": {"repo": "git+https://github.com/tmux/tmux.git"},
93+
},
94+
},
95+
["~/study/c/"],
96+
id="home-vs-absolute",
97+
),
98+
pytest.param(
99+
{
100+
"./study/c": {
101+
"cpython": {"repo": "git+https://github.com/python/cpython.git"},
102+
},
103+
"~/study/c/": {
104+
"tmux": {"repo": "git+https://github.com/tmux/tmux.git"},
105+
},
106+
},
107+
["~/study/c/"],
108+
id="relative-vs-tilde",
109+
),
110+
],
111+
)
112+
def test_workspace_root_normalization(
113+
self,
114+
config: dict[str, t.Any],
115+
expected_roots: list[str],
116+
) -> None:
117+
"""Ensure format_config merges duplicate workspace roots."""
118+
formatted, _changes = format_config(config)
119+
assert list(formatted.keys()) == expected_roots
120+
68121
def test_sort_directories(self) -> None:
69122
"""Test that directories are sorted alphabetically."""
70123
config = {

0 commit comments

Comments
 (0)