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 b78a1e1 commit 1c484bd
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/version/commands/test_java.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import unittest
from pathlib import Path

from pontos.testing import temp_file
from pontos.testing import temp_directory, temp_file
from pontos.version.commands import JavaVersionCommand
from pontos.version.schemes import SemanticVersioningScheme

Expand All @@ -41,7 +41,7 @@

class GetCurrentJavaVersionCommandTestCase(unittest.TestCase):
def test_getting_version(self):
with temp_file(name="upgradeVersion.json", change_into=True):
with temp_directory(change_into=True):
version_file_path = Path("upgradeVersion.json")
version_file_path.write_text(
TEMPLATE_UPGRADE_VERSION_JSON, encoding="utf-8"
Expand All @@ -68,7 +68,7 @@ def test_getting_version(self):

class VerifyJavaVersionCommandTestCase(unittest.TestCase):
def test_verify_version(self):
with temp_file(name="upgradeVersion.json", change_into=True):
with temp_directory(change_into=True):
version_file_path = Path("upgradeVersion.json")
version_file_path.write_text(
TEMPLATE_UPGRADE_VERSION_JSON, encoding="utf-8"
Expand All @@ -90,7 +90,7 @@ def test_verify_version(self):

class UpdateJavaVersionCommandTestCase(unittest.TestCase):
def test_update_version(self):
with temp_file(name="upgradeVersion.json", change_into=True):
with temp_directory(change_into=True):
version_file_path = Path("upgradeVersion.json")
version_file_path.write_text(
TEMPLATE_UPGRADE_VERSION_JSON, encoding="utf-8"
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_update_version(self):
readme_file_path.unlink()

def test_forced_update_version(self):
with temp_file(name="upgradeVersion.json", change_into=True):
with temp_directory(change_into=True):
version_file_path = Path("upgradeVersion.json")
version_file_path.write_text(
TEMPLATE_UPGRADE_VERSION_JSON, encoding="utf-8"
Expand All @@ -147,3 +147,17 @@ def test_forced_update_version(self):

version_file_path.unlink()
readme_file_path.unlink()


class ProjectFileJavaVersionCommandTestCase(unittest.TestCase):
def test_project_file_not_found(self):
with temp_directory(change_into=True):
cmd = JavaVersionCommand(SemanticVersioningScheme)

self.assertFalse(cmd.project_found())

def test_project_file_found(self):
with temp_file(name="upgradeVersion.json", change_into=True):
cmd = JavaVersionCommand(SemanticVersioningScheme)

self.assertTrue(cmd.project_found())

0 comments on commit 1c484bd

Please sign in to comment.