Skip to content

Commit b774129

Browse files
committed
test(bump): add test cast that fails to bump correctly
#383
1 parent aa0debe commit b774129

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/test_bump_update_version_in_files.py

+49
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,36 @@
5959
command: my-command
6060
"""
6161

62+
MULTIPLE_VERSIONS_TO_UPDATE_POETRY_LOCK = """
63+
[[package]]
64+
name = "to-update-1"
65+
version = "1.2.9"
66+
67+
[[package]]
68+
name = "not-to-update"
69+
version = "1.3.3"
70+
71+
[[package]]
72+
name = "not-to-update"
73+
version = "1.3.3"
74+
75+
[[package]]
76+
name = "not-to-update"
77+
version = "1.3.3"
78+
79+
[[package]]
80+
name = "not-to-update"
81+
version = "1.3.3"
82+
83+
[[package]]
84+
name = "not-to-update"
85+
version = "1.3.3"
86+
87+
[[package]]
88+
name = "to-update-2"
89+
version = "1.2.9"
90+
"""
91+
6292
MULTIPLE_VERSIONS_INCREASE_STRING = 'version = "1.2.9"\n' * 30
6393
MULTIPLE_VERSIONS_REDUCE_STRING = 'version = "1.2.10"\n' * 30
6494

@@ -119,6 +149,13 @@ def docker_compose_file(tmpdir):
119149
return str(tmp_file)
120150

121151

152+
@pytest.fixture(scope="function")
153+
def multiple_versions_to_update_poetry_lock(tmpdir):
154+
tmp_file = tmpdir.join("pyproject.toml")
155+
tmp_file.write(MULTIPLE_VERSIONS_TO_UPDATE_POETRY_LOCK)
156+
return str(tmp_file)
157+
158+
122159
@pytest.fixture(scope="function")
123160
def version_files(
124161
commitizen_config_file,
@@ -228,3 +265,15 @@ def test_file_version_inconsistent_error(
228265
"version_files are possibly inconsistent."
229266
)
230267
assert expected_msg in str(excinfo.value)
268+
269+
270+
def test_multiplt_versions_to_bump(multiple_versions_to_update_poetry_lock):
271+
old_version = "1.2.9"
272+
new_version = "1.2.10"
273+
location = f"{multiple_versions_to_update_poetry_lock}:version"
274+
275+
bump.update_version_in_files(old_version, new_version, [location])
276+
with open(multiple_versions_to_update_poetry_lock, "r") as f:
277+
data = f.read()
278+
assert len(re.findall(old_version, data)) == 0
279+
assert len(re.findall(new_version, data)) == 2

0 commit comments

Comments
 (0)