Skip to content

Commit fde3b72

Browse files
committed
test(bump): add test case that fails when using regex with version file without end of line
if we bump with version file with no end of line through regex, the last version will be ignored
1 parent dcb18bb commit fde3b72

12 files changed

+67
-7
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repos:
55
hooks:
66
- id: check-vcs-permalinks
77
- id: end-of-file-fixer
8-
exclude: "tests/test_*/*"
8+
exclude: "tests/[test_*|data]/*"
99
- id: trailing-whitespace
1010
args: [--markdown-linebreak-ext=md]
1111
- id: debug-statements
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[[package]]
2+
name = "to-update-1"
3+
version = "1.2.9"
4+
5+
[[package]]
6+
name = "not-to-update"
7+
version = "1.3.3"
8+
9+
[[package]]
10+
name = "not-to-update"
11+
version = "1.3.3"
12+
13+
[[package]]
14+
name = "not-to-update"
15+
version = "1.3.3"
16+
17+
[[package]]
18+
name = "not-to-update"
19+
version = "1.3.3"
20+
21+
[[package]]
22+
name = "not-to-update"
23+
version = "1.3.3"
24+
25+
[[package]]
26+
name = "to-update-2"
27+
version = "1.2.9"

tests/test_bump_update_version_in_files.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
MULTIPLE_VERSIONS_INCREASE_STRING = 'version = "1.2.9"\n' * 30
99
MULTIPLE_VERSIONS_REDUCE_STRING = 'version = "1.2.10"\n' * 30
1010

11-
TESTING_FILE_PREFIX = "tests/testing_version_files"
11+
TESTING_FILE_PREFIX = "tests/data"
1212

1313

1414
@pytest.fixture(scope="function")
@@ -19,7 +19,7 @@ def commitizen_config_file(tmpdir):
1919

2020

2121
@pytest.fixture(scope="function")
22-
def python_version_file(tmpdir):
22+
def python_version_file(tmpdir, request):
2323
tmp_file = tmpdir.join("__verion__.py")
2424
copyfile(f"{TESTING_FILE_PREFIX}/sample_version.py", str(tmp_file))
2525
return str(tmp_file)
@@ -67,12 +67,18 @@ def docker_compose_file(tmpdir):
6767
return str(tmp_file)
6868

6969

70-
@pytest.fixture(scope="function")
71-
def multiple_versions_to_update_poetry_lock(tmpdir):
70+
@pytest.fixture(
71+
scope="function",
72+
params=(
73+
"multiple_versions_to_update_pyproject.toml",
74+
"multiple_versions_to_update_pyproject_wo_eol.toml",
75+
),
76+
ids=("with_eol", "without_eol"),
77+
)
78+
def multiple_versions_to_update_poetry_lock(tmpdir, request):
7279
tmp_file = tmpdir.join("pyproject.toml")
7380
copyfile(
74-
f"{TESTING_FILE_PREFIX}/multiple_versions_to_update_pyproject.toml",
75-
str(tmp_file),
81+
f"{TESTING_FILE_PREFIX}/{request.param}", str(tmp_file),
7682
)
7783
return str(tmp_file)
7884

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[[package]]
2+
name = "to-update-1"
3+
version = "1.2.10"
4+
5+
[[package]]
6+
name = "not-to-update"
7+
version = "1.3.3"
8+
9+
[[package]]
10+
name = "not-to-update"
11+
version = "1.3.3"
12+
13+
[[package]]
14+
name = "not-to-update"
15+
version = "1.3.3"
16+
17+
[[package]]
18+
name = "not-to-update"
19+
version = "1.3.3"
20+
21+
[[package]]
22+
name = "not-to-update"
23+
version = "1.3.3"
24+
25+
[[package]]
26+
name = "to-update-2"
27+
version = "1.2.10"

0 commit comments

Comments
 (0)