This commit is contained in:
bom 2023-02-24 11:02:11 +01:00
parent a09eaa7521
commit c6ef13ca7c
2 changed files with 21 additions and 14 deletions

View file

@ -31,13 +31,6 @@ class VersionRepository():
return version
class ReleaseRepository():
def __init__(self, version_repository: VersionRepository):
self.version_repository = version_repository
def get_current_release(self) -> Release:
pass
class ReleaseTypeRepository():
def __init__(self, git_api, environment_api=None):
self.git_api = git_api
@ -55,3 +48,11 @@ class ReleaseTypeRepository():
return ReleaseType.SNAPSHOT
else:
return None
class ReleaseRepository():
def __init__(self, version_repository: VersionRepository, release_type_repository: ReleaseTypeRepository):
self.version_repository = version_repository
self.release_type_repository = release_type_repository
def get_current_release(self) -> Release:
return Release(self.release_type_repository.get_release_type(), self.version_repository.get_version())

View file

@ -1,6 +1,3 @@
from domain import ReleaseType, Release
from infrastructure import GitRepository, VersionRepository, ReleaseRepository
from infrastructure_api import GitApi
from pathlib import Path
import sys
import os
@ -20,8 +17,11 @@ sys.path.append(parent)
# now we can import the module in the parent
# directory.
from domain import ReleaseType, Release
from infrastructure import ReleaseTypeRepository, VersionRepository, ReleaseRepository
from infrastructure_api import GitApi
def TestGitApi(GitApi):
class TestGitApi(GitApi):
def __init__(self, commit_string):
self.commit_string = commit_string
@ -158,7 +158,13 @@ def test_release_repository(tmp_path):
f.write_text(contents)
# test
sut = ReleaseRepository(VersionRepository(f))
current_release = sut.get_current_release()
sut = ReleaseRepository(VersionRepository(f), ReleaseTypeRepository(TestGitApi('MINOR test')))
release = sut.get_current_release()
assert current_release.version is not None
assert release.version is not None
def test_release_type_repository():
sut = ReleaseTypeRepository(TestGitApi('MINOR test'))
release_type = sut.get_release_type()
assert release_type is ReleaseType.MINOR