Skip to content

Commit badc189

Browse files
committed
tests/discover(add[scope]): cover user and project configs
1 parent dce6618 commit badc189

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

tests/cli/test_discover.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ def _fake_save(path: pathlib.Path, data: dict[str, t.Any]) -> None:
698698
assert "Successfully updated" in caplog.text
699699

700700

701-
@pytest.mark.xfail(reason="discover uses ./ for user-level configs (#487)", strict=True)
702701
def test_discover_user_config_prefers_absolute_workspace_label(
703702
tmp_path: pathlib.Path,
704703
monkeypatch: MonkeyPatch,
@@ -756,6 +755,46 @@ def test_discover_user_config_prefers_absolute_workspace_label(
756755
assert set(config_data["~/study/golang/"]) == {"moby", "typescript-go"}
757756

758757

758+
def test_discover_project_config_retains_relative_workspace_label(
759+
tmp_path: pathlib.Path,
760+
monkeypatch: MonkeyPatch,
761+
) -> None:
762+
import yaml
763+
764+
home = tmp_path / "home"
765+
home.mkdir()
766+
monkeypatch.setenv("HOME", str(home))
767+
768+
project_root = tmp_path / "project"
769+
project_root.mkdir()
770+
monkeypatch.chdir(project_root)
771+
772+
init_git_repo(project_root / "repo-a", "git+https://github.com/example/repo-a.git")
773+
init_git_repo(project_root / "repo-b", "git+https://github.com/example/repo-b.git")
774+
775+
config_file = project_root / ".vcspull.yaml"
776+
config_file.write_text(
777+
yaml.dump({}),
778+
encoding="utf-8",
779+
)
780+
781+
discover_repos(
782+
scan_dir_str=str(project_root),
783+
config_file_path_str=str(config_file),
784+
recursive=False,
785+
workspace_root_override=None,
786+
yes=True,
787+
dry_run=False,
788+
)
789+
790+
with config_file.open(encoding="utf-8") as fh:
791+
config_data = yaml.safe_load(fh)
792+
793+
assert config_data is not None
794+
assert "./" in config_data
795+
assert set(config_data["./"]) == {"repo-a", "repo-b"}
796+
797+
759798
@pytest.mark.parametrize(
760799
list(DiscoverInvalidWorkspaceFixture._fields),
761800
DISCOVER_INVALID_WORKSPACE_FIXTURES,

0 commit comments

Comments
 (0)