|
21 | 21 | DryRunExit,
|
22 | 22 | ExitCode,
|
23 | 23 | ExpectedExit,
|
| 24 | + GetNextExit, |
24 | 25 | InvalidManualVersion,
|
25 | 26 | NoCommitsFoundError,
|
26 | 27 | NoneIncrementExit,
|
@@ -1462,3 +1463,63 @@ def test_bump_command_shows_description_when_use_help_option(
|
1462 | 1463 |
|
1463 | 1464 | out, _ = capsys.readouterr()
|
1464 | 1465 | file_regression.check(out, extension=".txt")
|
| 1466 | + |
| 1467 | + |
| 1468 | +@pytest.mark.usefixtures("tmp_commitizen_project") |
| 1469 | +def test_bump_get_next(mocker: MockFixture, capsys): |
| 1470 | + create_file_and_commit("feat: new file") |
| 1471 | + |
| 1472 | + testargs = ["cz", "bump", "--yes", "--get-next"] |
| 1473 | + mocker.patch.object(sys, "argv", testargs) |
| 1474 | + with pytest.raises(GetNextExit): |
| 1475 | + cli.main() |
| 1476 | + |
| 1477 | + out, _ = capsys.readouterr() |
| 1478 | + assert "0.2.0" in out |
| 1479 | + |
| 1480 | + tag_exists = git.tag_exist("0.2.0") |
| 1481 | + assert tag_exists is False |
| 1482 | + |
| 1483 | + |
| 1484 | +@pytest.mark.usefixtures("tmp_commitizen_project") |
| 1485 | +def test_bump_get_next__changelog_is_not_allowed(mocker: MockFixture): |
| 1486 | + create_file_and_commit("feat: new file") |
| 1487 | + |
| 1488 | + testargs = ["cz", "bump", "--yes", "--get-next", "--changelog"] |
| 1489 | + mocker.patch.object(sys, "argv", testargs) |
| 1490 | + |
| 1491 | + with pytest.raises(NotAllowed): |
| 1492 | + cli.main() |
| 1493 | + |
| 1494 | + |
| 1495 | +@pytest.mark.usefixtures("tmp_commitizen_project") |
| 1496 | +def test_bump_get_next__changelog_to_stdout_is_not_allowed(mocker: MockFixture): |
| 1497 | + create_file_and_commit("feat: new file") |
| 1498 | + |
| 1499 | + testargs = ["cz", "bump", "--yes", "--get-next", "--changelog-to-stdout"] |
| 1500 | + mocker.patch.object(sys, "argv", testargs) |
| 1501 | + |
| 1502 | + with pytest.raises(NotAllowed): |
| 1503 | + cli.main() |
| 1504 | + |
| 1505 | + |
| 1506 | +@pytest.mark.usefixtures("tmp_commitizen_project") |
| 1507 | +def test_bump_get_next__manual_version_is_not_allowed(mocker: MockFixture): |
| 1508 | + create_file_and_commit("feat: new file") |
| 1509 | + |
| 1510 | + testargs = ["cz", "bump", "--yes", "--get-next", "0.2.1"] |
| 1511 | + mocker.patch.object(sys, "argv", testargs) |
| 1512 | + |
| 1513 | + with pytest.raises(NotAllowed): |
| 1514 | + cli.main() |
| 1515 | + |
| 1516 | + |
| 1517 | +@pytest.mark.usefixtures("tmp_commitizen_project") |
| 1518 | +def test_bump_get_next__no_eligible_commits_raises(mocker: MockFixture): |
| 1519 | + create_file_and_commit("chore: new commit") |
| 1520 | + |
| 1521 | + testargs = ["cz", "bump", "--yes", "--get-next"] |
| 1522 | + mocker.patch.object(sys, "argv", testargs) |
| 1523 | + |
| 1524 | + with pytest.raises(NoneIncrementExit): |
| 1525 | + cli.main() |
0 commit comments