test: Add e2e test for the path regex exclusion

This commit is contained in:
Baptiste Roux
2023-02-01 17:56:22 +01:00
parent 8cbdd9f408
commit 2cc477e551

View File

@@ -65,7 +65,8 @@ def test_repos_find_non_git_repos():
@pytest.mark.parametrize("default", [True, False])
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
def test_repos_find(configtype, default):
@pytest.mark.parametrize("exclude", [None, "^.*/repo2$", "^not_matching$"])
def test_repos_find(configtype, exclude, default):
with tempfile.TemporaryDirectory() as tmpdir:
shell(
f"""
@@ -101,9 +102,11 @@ def test_repos_find(configtype, default):
args = ["repos", "find", "local", tmpdir]
if not default:
args += ["--format", configtype]
if exclude:
args += ["--exclude", exclude]
cmd = grm(args)
assert cmd.returncode == 0
assert len(cmd.stderr) == 0
assert len(cmd.stderr) == (37 if exclude == "^.*/repo2$" and not default else 0)
if default or configtype == "toml":
output = toml.loads(cmd.stdout)
@@ -120,7 +123,9 @@ def test_repos_find(configtype, default):
assert set(tree.keys()) == {"root", "repos"}
assert tree["root"] == tmpdir
assert isinstance(tree["repos"], list)
assert len(tree["repos"]) == 2
assert len(tree["repos"]) == (
1 if exclude == "^.*/repo2$" and not default else 2
)
repo1 = [r for r in tree["repos"] if r["name"] == "repo1"][0]
assert repo1["worktree_setup"] is False
@@ -137,6 +142,9 @@ def test_repos_find(configtype, default):
assert someremote["type"] == "ssh"
assert someremote["url"] == "ssh://example.com/repo2.git"
if exclude == "^.*/repo2$" and not default:
assert [r for r in tree["repos"] if r["name"] == "repo2"] == []
else:
repo2 = [r for r in tree["repos"] if r["name"] == "repo2"][0]
assert repo2["worktree_setup"] is False
assert isinstance(repo1["remotes"], list)