|
1 | 1 | """ |
2 | | -Unit tests for branch numbering options (sequential vs timestamp). |
| 2 | +Unit tests verifying --branch-numbering removal (v0.10.0). |
3 | 3 |
|
4 | | -Tests cover: |
5 | | -- Persisting branch_numbering in init-options.json |
6 | | -- Default value when branch_numbering is None |
7 | | -- Validation of branch_numbering values |
| 4 | +Branch numbering is now managed entirely by the git extension's config. |
| 5 | +The --branch-numbering flag was removed from `specify init`. |
8 | 6 | """ |
9 | 7 |
|
10 | | -import json |
11 | 8 | from pathlib import Path |
12 | 9 |
|
13 | | -from specify_cli import save_init_options |
14 | 10 |
|
| 11 | +class TestBranchNumberingFlagRemoved: |
| 12 | + """--branch-numbering flag was removed in v0.10.0.""" |
15 | 13 |
|
16 | | -class TestSaveBranchNumbering: |
17 | | - """Tests for save_init_options with branch_numbering.""" |
18 | | - |
19 | | - def test_save_branch_numbering_timestamp(self, tmp_path: Path): |
20 | | - opts = {"branch_numbering": "timestamp", "ai": "claude"} |
21 | | - save_init_options(tmp_path, opts) |
22 | | - |
23 | | - saved = json.loads((tmp_path / ".specify/init-options.json").read_text()) |
24 | | - assert saved["branch_numbering"] == "timestamp" |
25 | | - |
26 | | - def test_save_branch_numbering_sequential(self, tmp_path: Path): |
27 | | - opts = {"branch_numbering": "sequential", "ai": "claude"} |
28 | | - save_init_options(tmp_path, opts) |
29 | | - |
30 | | - saved = json.loads((tmp_path / ".specify/init-options.json").read_text()) |
31 | | - assert saved["branch_numbering"] == "sequential" |
32 | | - |
33 | | - def test_branch_numbering_defaults_to_sequential(self, tmp_path: Path): |
34 | | - from typer.testing import CliRunner |
35 | | - from specify_cli import app |
36 | | - |
37 | | - project_dir = tmp_path / "proj" |
38 | | - runner = CliRunner() |
39 | | - result = runner.invoke(app, ["init", str(project_dir), "--integration", "claude", "--ignore-agent-tools", "--script", "sh"]) |
40 | | - assert result.exit_code == 0 |
41 | | - |
42 | | - saved = json.loads((project_dir / ".specify/init-options.json").read_text()) |
43 | | - assert saved["branch_numbering"] == "sequential" |
44 | | - |
45 | | - |
46 | | -class TestBranchNumberingValidation: |
47 | | - """Tests for branch_numbering CLI validation via CliRunner.""" |
48 | | - |
49 | | - def test_invalid_branch_numbering_rejected(self, tmp_path: Path): |
50 | | - from typer.testing import CliRunner |
51 | | - from specify_cli import app |
52 | | - |
53 | | - runner = CliRunner() |
54 | | - result = runner.invoke(app, ["init", str(tmp_path / "proj"), "--integration", "claude", "--branch-numbering", "foobar", "--ignore-agent-tools"]) |
55 | | - assert result.exit_code == 1 |
56 | | - assert "Invalid --branch-numbering" in result.output |
57 | | - |
58 | | - def test_valid_branch_numbering_sequential(self, tmp_path: Path): |
59 | | - from typer.testing import CliRunner |
60 | | - from specify_cli import app |
61 | | - |
62 | | - runner = CliRunner() |
63 | | - result = runner.invoke(app, ["init", str(tmp_path / "proj"), "--integration", "claude", "--branch-numbering", "sequential", "--ignore-agent-tools", "--script", "sh"]) |
64 | | - assert result.exit_code == 0 |
65 | | - assert "Invalid --branch-numbering" not in (result.output or "") |
66 | | - |
67 | | - def test_valid_branch_numbering_timestamp(self, tmp_path: Path): |
| 14 | + def test_branch_numbering_flag_is_rejected(self, tmp_path: Path): |
68 | 15 | from typer.testing import CliRunner |
69 | 16 | from specify_cli import app |
70 | 17 |
|
71 | 18 | runner = CliRunner() |
72 | | - result = runner.invoke(app, ["init", str(tmp_path / "proj"), "--integration", "claude", "--branch-numbering", "timestamp", "--ignore-agent-tools", "--script", "sh"]) |
73 | | - assert result.exit_code == 0 |
74 | | - assert "Invalid --branch-numbering" not in (result.output or "") |
| 19 | + result = runner.invoke(app, [ |
| 20 | + "init", str(tmp_path / "proj"), "--integration", "claude", |
| 21 | + "--branch-numbering", "sequential", "--ignore-agent-tools", |
| 22 | + ]) |
| 23 | + assert result.exit_code != 0, "--branch-numbering should be rejected" |
| 24 | + assert "No such option" in result.output or "no such option" in result.output.lower() |
0 commit comments