Skip to content

Commit

Permalink
Also test that all 'parts' can be used in 'replace'
Browse files Browse the repository at this point in the history
  • Loading branch information
florisla committed Dec 7, 2018
1 parent 51fc23f commit 96072cc
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tests/test_cli.py
Expand Up @@ -767,7 +767,7 @@ def test_message_from_config_file(tmpdir, capsys, vcs):

def test_all_parts_in_message_and_serialize_and_tag_name_from_config_file(tmpdir, capsys, vcs):
"""
Ensure that major/minor/patch *and* custom parts can be used everywhere.
Ensure that major/minor/patch *and* custom parts can be used everywhere.
- As [part] in 'serialize'.
- As new_[part] and previous_[part] in 'message'.
Expand All @@ -792,7 +792,8 @@ def test_all_parts_in_message_and_serialize_and_tag_name_from_config_file(tmpdir
message: {current_version}/{current_major}.{current_minor}.{current_patch} custom {current_custom} becomes {new_version}/{new_major}.{new_minor}.{new_patch} custom {new_custom}
tag_name: from-{current_version}-aka-{current_major}.{current_minor}.{current_patch}-custom-{current_custom}-to-{new_version}-aka-{new_major}.{new_minor}.{new_patch}-custom-{new_custom}
[bumpversion:part:custom] """)
[bumpversion:part:custom]
""")

main(['major', 'VERSION'])

Expand All @@ -803,6 +804,35 @@ def test_all_parts_in_message_and_serialize_and_tag_name_from_config_file(tmpdir
assert b'from-400.1.2.101-aka-400.1.2-custom-101-to-401.2.3.102-aka-401.2.3-custom-102' in tag_out


def test_all_parts_in_replace_from_config_file(tmpdir, capsys, vcs):
"""
Ensure that major/minor/patch *and* custom parts can be used in 'replace'.
"""
tmpdir.chdir()
check_call([vcs, "init"])
tmpdir.join("VERSION").write("my version is 400.1.2.101\n")
check_call([vcs, "add", "VERSION"])
check_call([vcs, "commit", "-m", "initial commit"])

tmpdir.join(".bumpversion.cfg").write("""[bumpversion]
current_version: 400.1.2.101
new_version: 401.2.3.102
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+).(?P<custom>\d+)
serialize = {major}.{minor}.{patch}.{custom}
commit: True
tag: False
[bumpversion:part:custom]
[bumpversion:VERSION]
search = my version is {current_version}
replace = my version is {new_major}.{new_minor}.{new_patch}.{new_custom}""")

main(['major', 'VERSION'])
log = check_output([vcs, "log", "-p"])
assert b'+my version is 401.2.3.102' in log


def test_unannotated_tag(tmpdir, vcs):
tmpdir.chdir()
check_call([vcs, "init"])
Expand Down

0 comments on commit 96072cc

Please sign in to comment.