diff --git a/infrastructure.py b/infrastructure.py index 8234a98..d1d844a 100644 --- a/infrastructure.py +++ b/infrastructure.py @@ -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()) diff --git a/test/test_infrastructure.py b/test/test_infrastructure.py index d7d28fd..a767ef5 100644 --- a/test/test_infrastructure.py +++ b/test/test_infrastructure.py @@ -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