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 return version
class ReleaseRepository():
def __init__(self, version_repository: VersionRepository):
self.version_repository = version_repository
def get_current_release(self) -> Release:
pass
class ReleaseTypeRepository(): class ReleaseTypeRepository():
def __init__(self, git_api, environment_api=None): def __init__(self, git_api, environment_api=None):
self.git_api = git_api self.git_api = git_api
@ -55,3 +48,11 @@ class ReleaseTypeRepository():
return ReleaseType.SNAPSHOT return ReleaseType.SNAPSHOT
else: else:
return None 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 from pathlib import Path
import sys import sys
import os import os
@ -20,8 +17,11 @@ sys.path.append(parent)
# now we can import the module in the parent # now we can import the module in the parent
# directory. # 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): def __init__(self, commit_string):
self.commit_string = commit_string self.commit_string = commit_string
@ -158,7 +158,13 @@ def test_release_repository(tmp_path):
f.write_text(contents) f.write_text(contents)
# test # test
sut = ReleaseRepository(VersionRepository(f)) sut = ReleaseRepository(VersionRepository(f), ReleaseTypeRepository(TestGitApi('MINOR test')))
current_release = sut.get_current_release() 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