From 1493f5ffe2a190c41de90aa7f680a20f20b95244 Mon Sep 17 00:00:00 2001 From: Stefan Tolksdorf Date: Wed, 27 Sep 2023 19:12:39 +0200 Subject: [PATCH] Add test for get_current_version --- tests/version/commands/test_java.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/version/commands/test_java.py b/tests/version/commands/test_java.py index e6d2dda3..81454d39 100644 --- a/tests/version/commands/test_java.py +++ b/tests/version/commands/test_java.py @@ -119,6 +119,34 @@ def test_update_version(self): version_file_path.unlink() readme_file_path.unlink() + def test_no_update_version(self): + version_file_path = Path("upgradeVersion.json") + version_file_path.write_text( + TEMPLATE_UPGRADE_VERSION_JSON, encoding="utf-8" + ) + + version = "2023.9.3" + readme_file_path = Path("README.md") + readme_file_path.write_text( + TEMPLATE_UPGRADE_VERSION_MARKDOWN.format(version), encoding="utf-8" + ) + + updated_version_obj = JavaVersionCommand( + SemanticVersioningScheme + ).update_version(SemanticVersioningScheme.parse_version(version)) + + self.assertEqual(updated_version_obj.previous, SemanticVersioningScheme.parse_version(version)) + self.assertEqual(updated_version_obj.new, SemanticVersioningScheme.parse_version(new_version)) + self.assertEqual( + updated_version_obj.changed_files, [] + ) + + content = readme_file_path.read_text(encoding="UTF-8") + self.assertEqual(content, TEMPLATE_UPGRADE_VERSION_MARKDOWN.format(version)) + + version_file_path.unlink() + readme_file_path.unlink() + def test_forced_update_version(self): with temp_directory(change_into=True): version_file_path = Path("upgradeVersion.json")