Fix service test and cleanup services
We now create a temporary git repository that creates a release commit. Remove whitespaces, unused imports.
This commit is contained in:
parent
9dc32ac92f
commit
0d36a8a66a
2 changed files with 31 additions and 21 deletions
|
@ -16,11 +16,10 @@ class PrepareReleaseService():
|
|||
self.git_api.commit(commit_message)
|
||||
|
||||
def write_and_commit_release(self):
|
||||
self.__write_and_commit_version(self.release.release_version(), commit_message=f'Release {self.release.release_version().get_version_string()}')
|
||||
self.__write_and_commit_version(self.release.release_version(), commit_message=f'Release v{self.release.release_version().get_version_string()}')
|
||||
|
||||
def write_and_commit_bump(self):
|
||||
self.__write_and_commit_version(self.release.bump_version(), commit_message=f'Version bump')
|
||||
|
||||
self.__write_and_commit_version(self.release.bump_version(), commit_message='Version bump')
|
||||
|
||||
class TagAndPushReleaseService():
|
||||
|
||||
|
@ -32,5 +31,3 @@ class TagAndPushReleaseService():
|
|||
message = 'Release ' + annotation
|
||||
self.git_api.tag_annotated(annotation, message, 1)
|
||||
# self.git_api.push()
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import pytest as pt
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import os
|
||||
|
@ -17,26 +18,38 @@ sys.path.append(parent)
|
|||
# now we can import the module in the parent
|
||||
# directory.
|
||||
|
||||
from services import InitReleaseService
|
||||
from services import PrepareReleaseService
|
||||
from domain import ReleaseType
|
||||
from infrastructure import VersionRepository, ReleaseRepository, ReleaseTypeRepository
|
||||
from infrastructure_api import GitApi
|
||||
|
||||
def test_init_release_service(tmp_path):
|
||||
def change_test_dir( tmp_path: Path, monkeypatch: pt.MonkeyPatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
def test_prepare_release_service(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
|
||||
# init
|
||||
file_name = 'config.json'
|
||||
with open(f'test/resources/{file_name}', 'r') as gradle_file:
|
||||
contents = gradle_file.read()
|
||||
|
||||
with open(f'test/resources/{file_name}', 'r') as json_file:
|
||||
contents = json_file.read()
|
||||
f = tmp_path / file_name
|
||||
f.write_text(contents)
|
||||
change_test_dir(tmp_path, monkeypatch) # change the context of the script execution to tmp_path
|
||||
|
||||
git_api = GitApi()
|
||||
git_api.init()
|
||||
git_api.add_file(file_name)
|
||||
git_api.commit("MINOR release")
|
||||
|
||||
repo = ReleaseRepository(VersionRepository(f), ReleaseTypeRepository(GitApi()), 'main')
|
||||
release_service = InitReleaseService(repo)
|
||||
version = release_service.get_version().create_release_version(ReleaseType.MINOR)
|
||||
prepare_release_service = PrepareReleaseService(repo)
|
||||
prepare_release_service.main_branch = "main"
|
||||
prepare_release_service.write_and_commit_release()
|
||||
|
||||
assert "123.124.0" in version.get_version_string()
|
||||
latest_commit = git_api.get_latest_commit()
|
||||
|
||||
version = version.create_bump_version()
|
||||
assert '"Release v123.124.0 "\n' in latest_commit
|
||||
|
||||
assert "123.124.1-SNAPSHOT" in version.get_version_string()
|
||||
prepare_release_service.write_and_commit_bump()
|
||||
latest_commit = git_api.get_latest_commit()
|
||||
|
||||
assert '"Version bump "\n' in latest_commit
|
||||
|
|
Loading…
Reference in a new issue