Skip to content

Commit aaeafac

Browse files
leoxiao2012claude
andcommitted
fix(test): update slash tests to match no-slash-in-prefix behavior
Update test assertions to expect "must not contain slashes" error message and reject trailing slashes, matching the current validation logic that disallows any slash in --prefix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7b0c118 commit aaeafac

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

tests/test_timestamp_branches.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,14 +1575,13 @@ def test_prefix_allow_existing_branch(self, git_repo: Path):
15751575
).stdout.strip()
15761576
assert current == "feature/010-pre-exist"
15771577

1578-
def test_prefix_trailing_slash_optional(self, git_repo: Path):
1579-
"""Passing 'feature/' (with trailing slash) works identically to 'feature'."""
1578+
def test_prefix_rejects_trailing_slash(self, git_repo: Path):
1579+
"""Passing 'feature/' (with trailing slash) is rejected — no slashes allowed."""
15801580
result = run_script(
1581-
git_repo, "--prefix", "feature/", "--short-name", "slash", "Trailing slash"
1581+
git_repo, "--dry-run", "--prefix", "feature/", "--short-name", "slash", "Trailing slash"
15821582
)
1583-
assert result.returncode == 0, result.stderr
1584-
branch = _parse_branch_from_stdout(result.stdout)
1585-
assert branch == "feature/001-slash", f"expected feature/001-slash, got: {branch}"
1583+
assert result.returncode != 0
1584+
assert "must not contain slashes" in result.stderr
15861585

15871586
def test_prefix_whitespace_trimmed(self, git_repo: Path):
15881587
"""Whitespace around prefix value is trimmed."""
@@ -1595,20 +1594,20 @@ def test_prefix_whitespace_trimmed(self, git_repo: Path):
15951594

15961595
@pytest.mark.parametrize("prefix", ["/", "//", "///", "////"], ids=["single", "double", "triple", "quad"])
15971596
def test_prefix_rejects_slash_only(self, git_repo: Path, prefix: str):
1598-
"""Slash-only values produce an empty segment after trimming the trailing '/'."""
1597+
"""Slash-only values are rejected — no slashes allowed at all."""
15991598
result = run_script(
16001599
git_repo, "--dry-run", "--prefix", prefix, "--short-name", "bad", "Bad prefix"
16011600
)
16021601
assert result.returncode != 0
1603-
assert "non-slash" in result.stderr.lower() or "single segment" in result.stderr.lower()
1602+
assert "must not contain slashes" in result.stderr
16041603

16051604
def test_prefix_rejects_embedded_slash(self, git_repo: Path):
16061605
"""Multi-segment prefix like 'feat/fix' is rejected."""
16071606
result = run_script(
16081607
git_repo, "--dry-run", "--prefix", "feat/fix", "--short-name", "bad", "Bad prefix"
16091608
)
16101609
assert result.returncode != 0
1611-
assert "single segment" in result.stderr
1610+
assert "must not contain slashes" in result.stderr
16121611

16131612
def test_prefix_rejects_whitespace_only(self, git_repo: Path):
16141613
"""Whitespace-only prefix value is rejected."""
@@ -1755,7 +1754,8 @@ def test_ps_prefix_rejects_embedded_slash(self, ps_git_repo: Path):
17551754
ps_git_repo, "-DryRun", "-Prefix", "feat/fix", "-ShortName", "bad", "Bad"
17561755
)
17571756
assert result.returncode != 0
1758-
assert "single segment" in result.stderr.lower() or "single segment" in result.stdout.lower()
1757+
combined = (result.stderr + result.stdout).lower()
1758+
assert "must not contain slashes" in combined
17591759

17601760
@pytest.mark.parametrize("prefix", ["/", "//", "///", "////"], ids=["single", "double", "triple", "quad"])
17611761
def test_ps_prefix_rejects_slash_only(self, ps_git_repo: Path, prefix: str):
@@ -1765,16 +1765,16 @@ def test_ps_prefix_rejects_slash_only(self, ps_git_repo: Path, prefix: str):
17651765
)
17661766
assert result.returncode != 0
17671767
combined = (result.stderr + result.stdout).lower()
1768-
assert "non-slash" in combined or "single segment" in combined
1768+
assert "must not contain slashes" in combined
17691769

1770-
def test_ps_prefix_trailing_slash_optional(self, ps_git_repo: Path):
1771-
"""PowerShell: trailing slash is normalized."""
1770+
def test_ps_prefix_rejects_trailing_slash(self, ps_git_repo: Path):
1771+
"""PowerShell: trailing slash is rejected — no slashes allowed."""
17721772
result = run_ps_script(
1773-
ps_git_repo, "-Prefix", "feature/", "-ShortName", "slash", "Trailing slash"
1773+
ps_git_repo, "-DryRun", "-Prefix", "feature/", "-ShortName", "slash", "Trailing slash"
17741774
)
1775-
assert result.returncode == 0, result.stderr
1776-
branch = _parse_branch_from_stdout(result.stdout)
1777-
assert branch == "feature/001-slash"
1775+
assert result.returncode != 0
1776+
combined = (result.stderr + result.stdout).lower()
1777+
assert "must not contain slashes" in combined
17781778

17791779

17801780
@requires_bash
@@ -1898,7 +1898,7 @@ def test_ext_prefix_rejects_embedded_slash(self, ext_git_repo: Path):
18981898
ext_git_repo, "--dry-run", "--prefix", "feat/fix", "--short-name", "bad", "Bad"
18991899
)
19001900
assert result.returncode != 0
1901-
assert "single segment" in result.stderr
1901+
assert "must not contain slashes" in result.stderr
19021902

19031903
@pytest.mark.parametrize("prefix", ["/", "//", "///", "////"], ids=["single", "double", "triple", "quad"])
19041904
def test_ext_prefix_rejects_slash_only(self, ext_git_repo: Path, prefix: str):
@@ -1907,4 +1907,4 @@ def test_ext_prefix_rejects_slash_only(self, ext_git_repo: Path, prefix: str):
19071907
ext_git_repo, "--dry-run", "--prefix", prefix, "--short-name", "bad", "Bad"
19081908
)
19091909
assert result.returncode != 0
1910-
assert "non-slash" in result.stderr.lower() or "single segment" in result.stderr.lower()
1910+
assert "must not contain slashes" in result.stderr

0 commit comments

Comments
 (0)