add test for found issue

This commit is contained in:
Michael Jerger 2023-06-28 08:45:37 +02:00
parent c13d39b066
commit e86e6fe357
3 changed files with 26 additions and 1 deletions

View file

@ -16,6 +16,9 @@ class ReleaseService:
BuildFileRepository(base_dir), BuildFileRepository(base_dir),
) )
def update_release_type(self, release: Release, release_type_str: str):
release.update_release_type(ReleaseType[release_type_str])
def prepare_release(self, release: Release): def prepare_release(self, release: Release):
match release.release_type: match release.release_type:
case ReleaseType.MAJOR: case ReleaseType.MAJOR:

View file

@ -15,7 +15,7 @@ class ReleaseMixin(DevopsBuild):
def update_release_type(self, release_type_str: str): def update_release_type(self, release_type_str: str):
devops = self.devops_repo.get_devops(self.project) devops = self.devops_repo.get_devops(self.project)
release = devops.mixins[MixinType.RELEASE] release = devops.mixins[MixinType.RELEASE]
release.update_release_type(ReleaseType[release_type_str]) self.release_service.update_release_type(release, release_type_str)
def prepare_release(self): def prepare_release(self):
devops = self.devops_repo.get_devops(self.project) devops = self.devops_repo.get_devops(self.project)

View file

@ -0,0 +1,22 @@
import pytest
from pathlib import Path
from src.main.python.ddadevops.domain import (
ReleaseType,
MixinType,
)
from src.test.python.domain.helper import (
BuildFileRepositoryMock,
GitApiMock,
build_devops,
)
from src.main.python.ddadevops.application import ReleaseService
def test_sould_update_release_type():
sut = ReleaseService(GitApiMock(), BuildFileRepositoryMock("build.py"))
devops = build_devops({})
release = devops.mixins[MixinType.RELEASE]
sut.update_release_type(release, "MAJOR")
assert ReleaseType.MAJOR == release.release_type
with pytest.raises(Exception):
sut.update_release_type(release, "NOT_EXISTING")