Compare commits
4 commits
156d336314
...
e9301dedd1
Author | SHA1 | Date | |
---|---|---|---|
e9301dedd1 | |||
bb17017583 | |||
ea45671bea | |||
1dc5a1e9e8 |
3 changed files with 62 additions and 6 deletions
|
@ -22,7 +22,7 @@ from version_repository import VersionRepository
|
|||
from release_type import ReleaseType
|
||||
|
||||
def test_version():
|
||||
version = Version([1, 2, 3])
|
||||
version = Version([1, 2, 3], ReleaseType.SNAPSHOT)
|
||||
|
||||
version.increment(ReleaseType.SNAPSHOT)
|
||||
assert version.get_version_string() == "1.2.3-SNAPSHOT"
|
||||
|
@ -62,8 +62,63 @@ def test_gradle(tmp_path):
|
|||
|
||||
# test
|
||||
version_repo = VersionRepository.get(f)
|
||||
version = Version.create_release_version(ReleaseType.SNAPSHOT)
|
||||
version_repo.write_file(version.get_version_string)
|
||||
version_list = version_repo.version_list
|
||||
version = Version.create_release_version(version_list, ReleaseType.SNAPSHOT)
|
||||
version_repo.write_file(version.get_version_string())
|
||||
|
||||
# check
|
||||
assert 'version = "12.4.678-SNAPSHOT"' in f.read_text()
|
||||
|
||||
def test_json(tmp_path):
|
||||
# init
|
||||
file_name = 'config.json'
|
||||
with open(f'test/resources/{file_name}', 'r') as gradle_file:
|
||||
contents = gradle_file.read()
|
||||
|
||||
f = tmp_path / file_name
|
||||
f.write_text(contents)
|
||||
|
||||
# test
|
||||
version_repo = VersionRepository.get(f)
|
||||
version_list = version_repo.version_list
|
||||
version = Version.create_release_version(version_list, ReleaseType.SNAPSHOT)
|
||||
version_repo.write_file(version.get_version_string())
|
||||
|
||||
# check
|
||||
assert '"version": "123.123.456-SNAPSHOT"' in f.read_text()
|
||||
|
||||
def test_clojure(tmp_path):
|
||||
# init
|
||||
file_name = 'config.clj'
|
||||
with open(f'test/resources/{file_name}', 'r') as gradle_file:
|
||||
contents = gradle_file.read()
|
||||
|
||||
f = tmp_path / file_name
|
||||
f.write_text(contents)
|
||||
|
||||
# test
|
||||
version_repo = VersionRepository.get(f)
|
||||
version_list = version_repo.version_list
|
||||
version = Version.create_release_version(version_list, ReleaseType.SNAPSHOT)
|
||||
version_repo.write_file(version.get_version_string())
|
||||
|
||||
# check
|
||||
assert '1.1.3-SNAPSHOT' in f.read_text()
|
||||
|
||||
def test_python(tmp_path):
|
||||
# init
|
||||
file_name = 'config.py'
|
||||
with open(f'test/resources/{file_name}', 'r') as gradle_file:
|
||||
contents = gradle_file.read()
|
||||
|
||||
f = tmp_path / file_name
|
||||
f.write_text(contents)
|
||||
|
||||
# test
|
||||
version_repo = VersionRepository.get(f)
|
||||
version_list = version_repo.version_list
|
||||
version = Version.create_release_version(version_list, ReleaseType.SNAPSHOT)
|
||||
version_repo.write_file(version.get_version_string())
|
||||
|
||||
# check
|
||||
assert '3.1.3-SNAPSHOT' in f.read_text()
|
|
@ -3,8 +3,9 @@ from file_handlers import FileHandler
|
|||
|
||||
class Version():
|
||||
|
||||
def __init__(self, version_list: list):
|
||||
def __init__(self, version_list: list, release_type: ReleaseType):
|
||||
self.version_list = version_list
|
||||
self.release_type = release_type
|
||||
self.version_string = None
|
||||
self.is_snapshot = None
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class VersionRepository():
|
|||
|
||||
def load_file(self):
|
||||
self.file_handler = FileHandler.from_file_path(self.file)
|
||||
return file_handler
|
||||
return self.file_handler
|
||||
|
||||
def write_file(self, version_string):
|
||||
if self.file_handler is None:
|
||||
|
@ -28,7 +28,7 @@ class VersionRepository():
|
|||
def get(cls, file):
|
||||
inst = cls(file)
|
||||
|
||||
file_handler= inst.load_file(file)
|
||||
file_handler = inst.load_file()
|
||||
version_list, is_snapshot = inst.parse_file(file_handler)
|
||||
|
||||
inst.version_list = version_list
|
||||
|
|
Loading…
Reference in a new issue