Skip to content

Commit df787f1

Browse files
committed
Add test for moveable tags
1 parent fd2f577 commit df787f1

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[tool.pytest.ini_options]
2+
norecursedirs = [
3+
".*",
4+
"build",
5+
"dist",
6+
"{arch}",
7+
"*.egg",
8+
"venv",
9+
"requirements*",
10+
"lib",
11+
]
12+
python_files = "test*.py"
13+
addopts = [
14+
"--cov=bumpversion",
15+
"--cov-branch",
16+
"--cov-report=term",
17+
"--cov-report=html",
18+
]
19+
20+
[tool.bumpversion]
21+
commit = true
22+
tag = true
23+
current_version = "1.0.0"
24+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\-(?P<release>[a-z]+))?"
25+
serialize = [
26+
"{major}.{minor}.{patch}-{release}",
27+
"{major}.{minor}.{patch}"
28+
]
29+
moveable_tags = ["v{new_major}"]
30+
31+
[[tool.bumpversion.files]]
32+
filename = "example/__init__.py"
33+
34+
[[tool.bumpversion.files]]
35+
filename = "CHANGELOG.md"
36+
search = "**unreleased**"
37+
replace = """**unreleased**
38+
**v{new_version}**"""
39+
40+
[tool.bumpversion.parts.release]
41+
optional_value = "gamma"
42+
values =[
43+
"dev",
44+
"gamma",
45+
]
46+
47+
[tool.othertool]
48+
bake_cookies = true
49+
ignore-words-list = "sugar, salt, flour"

tests/test_cli/test_bump.py

+39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests the bump CLI subcommand."""
22

3+
import logging
34
import shutil
45
import subprocess
56
import traceback
@@ -394,3 +395,41 @@ def test_remote_config_doesnt_update(tmp_path, git_repo, runner):
394395
assert result.exit_code == 0
395396
assert config_file.read_text() == config_contents
396397
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

Comments
 (0)