WIP fixing tests

This commit is contained in:
erik 2023-05-02 13:10:27 +02:00
parent 97c5c4eb91
commit 8fd243a60d
2 changed files with 8 additions and 9 deletions

View file

@ -32,12 +32,11 @@ class MockReleaseTypeRepository():
return ReleaseType.MINOR
class MockReleaseRepository():
def __init__(self, version_repository: MockVersionRepository, release_type_repository: MockReleaseTypeRepository, main_branch: str):
def __init__(self, version_repository: MockVersionRepository, release_type_repository: MockReleaseTypeRepository):
self.version_repository = version_repository
self.release_type_repository = release_type_repository
self.main_branch = main_branch
self.get_release_count = 0
def get_release(self) -> ReleaseContext:
def get_release(self, main_branch) -> ReleaseContext:
self.get_release_count += 1
return ReleaseContext(self.release_type_repository.get_release_type(), self.version_repository.get_version(), self.main_branch)
return ReleaseContext(self.release_type_repository.get_release_type(), self.version_repository.get_version(), main_branch)

View file

@ -4,17 +4,17 @@ from src.test.python.release_mixin import MockGitApi
def test_prepare_release_service():
# init
mock_release_repo = MockReleaseRepository(MockVersionRepository(), MockReleaseTypeRepository(MockGitApi()), 'main')
mock_release_repo = MockReleaseRepository(MockVersionRepository(), MockReleaseTypeRepository(MockGitApi()))
prepare_release_service = PrepareReleaseService()
prepare_release_service.git_api = MockGitApi()
prepare_release_service.write_and_commit_release(mock_release_repo.get_release(), mock_release_repo.version_repository)
prepare_release_service.write_and_commit_release(mock_release_repo.get_release("main"), mock_release_repo.version_repository)
#test
assert prepare_release_service.git_api.add_file_count == 1
assert prepare_release_service.git_api.commit_count == 1
# init
prepare_release_service.write_and_commit_bump(mock_release_repo.get_release(), mock_release_repo.version_repository)
prepare_release_service.write_and_commit_bump(mock_release_repo.get_release("main"), mock_release_repo.version_repository)
# test
assert prepare_release_service.git_api.add_file_count == 2
@ -22,8 +22,8 @@ def test_prepare_release_service():
def test_tag_and_push_release_service():
# init
mock_release_repo = MockReleaseRepository(MockVersionRepository(), MockReleaseTypeRepository(MockGitApi()), 'main')
tag_and_push_release_service = TagAndPushReleaseService(MockGitApi())
mock_release_repo = MockReleaseRepository(MockVersionRepository(), MockReleaseTypeRepository(MockGitApi()))
tag_and_push_release_service = TagAndPushReleaseService(MockGitApi(), "main")
tag_and_push_release_service.tag_release(mock_release_repo)
tag_and_push_release_service.push_release()