Skip to content

Commit 19db421

Browse files
committed
Added test for commit status !minor
1 parent e6b4b46 commit 19db421

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

tests/test_bump.py

+81
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from bumpversion.exceptions import ConfigurationError, VersionNotFoundError
1212
from bumpversion.files import ConfiguredFile
1313
from bumpversion.scm import Git, SCMInfo
14+
from bumpversion.utils import run_command
1415
from tests.conftest import get_config_data, inside_dir
1516

1617

@@ -353,3 +354,83 @@ def test_key_path_required_for_toml_change(tmp_path: Path, caplog):
353354
ignore-words-list = "sugar, salt, flour"
354355
"""
355356
)
357+
358+
359+
def test_changes_to_files_are_committed(git_repo: Path, caplog):
360+
"""Any files changed during the bump are committed."""
361+
from bumpversion import config
362+
363+
# Arrange
364+
config_path = git_repo / ".bumpversion.toml"
365+
config_path.write_text(
366+
dedent(
367+
"""
368+
[tool.bumpversion]
369+
current_version = "0.1.26"
370+
allow_dirty = true
371+
commit = true
372+
373+
[[tool.bumpversion.files]]
374+
filename = "helm/charts/somechart/Chart.yaml"
375+
376+
"""
377+
),
378+
encoding="utf-8",
379+
)
380+
chart_path = git_repo / "helm" / "charts" / "somechart" / "Chart.yaml"
381+
382+
chart_path.parent.mkdir(parents=True, exist_ok=True)
383+
chart_path.write_text(
384+
dedent(
385+
"""
386+
appVersion: 0.1.26
387+
version: 0.1.26
388+
389+
"""
390+
)
391+
)
392+
393+
with inside_dir(git_repo):
394+
run_command(["git", "add", str(chart_path), str(config_path)])
395+
run_command(["git", "commit", "-m", "Initial commit"])
396+
397+
# Act
398+
from click.testing import CliRunner, Result
399+
from bumpversion import cli
400+
401+
runner: CliRunner = CliRunner()
402+
with inside_dir(git_repo):
403+
result: Result = runner.invoke(
404+
cli.cli,
405+
["bump", "-vv", "minor"],
406+
)
407+
408+
if result.exit_code != 0:
409+
print(caplog.text)
410+
print("Here is the output:")
411+
print(result.output)
412+
import traceback
413+
414+
print(traceback.print_exception(result.exc_info[1]))
415+
416+
# Assert
417+
assert result.exit_code == 0
418+
assert config_path.read_text() == dedent(
419+
"""
420+
[tool.bumpversion]
421+
current_version = "0.2.0"
422+
allow_dirty = true
423+
commit = true
424+
425+
[[tool.bumpversion.files]]
426+
filename = "helm/charts/somechart/Chart.yaml"
427+
428+
"""
429+
)
430+
assert chart_path.read_text() == dedent(
431+
"""
432+
appVersion: 0.2.0
433+
version: 0.2.0
434+
435+
"""
436+
)

0 commit comments

Comments
 (0)