|
1 | 1 | """Tests the bump CLI subcommand."""
|
2 | 2 |
|
| 3 | +import logging |
3 | 4 | import shutil
|
4 | 5 | import subprocess
|
5 | 6 | import traceback
|
@@ -394,3 +395,41 @@ def test_remote_config_doesnt_update(tmp_path, git_repo, runner):
|
394 | 395 | assert result.exit_code == 0
|
395 | 396 | assert config_file.read_text() == config_contents
|
396 | 397 | assert myfile.read_text() == "version = 1.1.0\n"
|
| 398 | + |
| 399 | + |
| 400 | +def test_moveable_tags(git_repo: Path, fixtures_path: Path, runner, caplog): |
| 401 | + """The current version is not required in the configuration.""" |
| 402 | + caplog.set_level(logging.DEBUG) |
| 403 | + config_file = git_repo / ".bumpversion.toml" |
| 404 | + orig_config = fixtures_path / "basic_cfg_moveable.toml" |
| 405 | + shutil.copy(orig_config, config_file) |
| 406 | + changelog_path = git_repo / "CHANGELOG.md" |
| 407 | + changelog_path.write_text("**unreleased**") |
| 408 | + mkdir_path = git_repo / "example" |
| 409 | + mkdir_path.mkdir() |
| 410 | + init_path = mkdir_path / "__init__.py" |
| 411 | + init_path.write_text('__version__ = "1.0.0"') |
| 412 | + |
| 413 | + # Act |
| 414 | + with inside_dir(git_repo): |
| 415 | + subprocess.run(["git", "add", "."], check=True) |
| 416 | + subprocess.run(["git", "commit", "-m", "added files"], check=True) |
| 417 | + |
| 418 | + result: Result = runner.invoke( |
| 419 | + cli.cli, |
| 420 | + [ |
| 421 | + "bump", |
| 422 | + "-vv", |
| 423 | + "--dry-run", |
| 424 | + "minor", |
| 425 | + ], |
| 426 | + ) |
| 427 | + |
| 428 | + # Assert |
| 429 | + if result.exit_code != 0: |
| 430 | + print("Here is the output:") |
| 431 | + print(result.output) |
| 432 | + print(traceback.print_exception(*result.exc_info)) |
| 433 | + |
| 434 | + assert result.exit_code == 0 |
| 435 | + assert "Would tag moveable tag 'v1'" in caplog.text |
0 commit comments