Skip to content

Commit

Permalink
Add test for get_current_version
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanTolksdorf committed Sep 27, 2023
1 parent ea4162d commit 24fa909
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/version/commands/test_java.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
}
"""

TEMPLATE_UPGRADE_VERSION_WITH_LINE_JSON = """{
"files": [
{
"path": "README.md",
"line": {}
}
]
}
"""

TEMPLATE_UPGRADE_VERSION_MARKDOWN = """# Task service
**task service**: Version {}
Expand Down Expand Up @@ -265,6 +275,39 @@ def test_forced_update_version(self):
version_file_path.unlink()
readme_file_path.unlink()

def test_update_version_upgrade_config_with_wrong_line_number(self):
exp_err_msg = (
r"Line has no version, "
r"file:'/tmp/.*/README\.md' "
r"lineNo:4 "
r"content:''"
)
with temp_directory(change_into=True), self.assertRaisesRegex(
VersionError,
exp_err_msg,
):
version_file_path = Path("upgradeVersion.json")
version_file_path.write_text(
TEMPLATE_UPGRADE_VERSION_WITH_LINE_JSON.format("4"), 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",
)

new_version = "2023.9.4"
JavaVersionCommand(
SemanticVersioningScheme
).update_version(
SemanticVersioningScheme.parse_version(new_version)
)

version_file_path.unlink()
readme_file_path.unlink()


class ProjectFileJavaVersionCommandTestCase(unittest.TestCase):
def test_project_file_not_found(self):
Expand Down

0 comments on commit 24fa909

Please sign in to comment.