|
|
|
@ -18,8 +18,7 @@ sys.path.append(parent)
|
|
|
|
|
# now we can import the module in the parent
|
|
|
|
|
# directory.
|
|
|
|
|
|
|
|
|
|
from services import PrepareReleaseService
|
|
|
|
|
from domain import ReleaseType
|
|
|
|
|
from services import PrepareReleaseService, TagAndPushReleaseService
|
|
|
|
|
from infrastructure import VersionRepository, ReleaseRepository, ReleaseTypeRepository
|
|
|
|
|
from infrastructure_api import GitApi
|
|
|
|
|
|
|
|
|
@ -53,3 +52,28 @@ def test_prepare_release_service(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
|
|
|
|
|
latest_commit = git_api.get_latest_commit()
|
|
|
|
|
|
|
|
|
|
assert '"Version bump "\n' in latest_commit
|
|
|
|
|
|
|
|
|
|
def test_tag_and_push_release_service(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
|
|
|
|
|
# init
|
|
|
|
|
file_name = 'config.json'
|
|
|
|
|
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')
|
|
|
|
|
|
|
|
|
|
prepare_release_service = PrepareReleaseService(repo)
|
|
|
|
|
prepare_release_service.main_branch = "main"
|
|
|
|
|
prepare_release_service.write_and_commit_release()
|
|
|
|
|
|
|
|
|
|
tag_and_push_release_service = TagAndPushReleaseService(git_api)
|
|
|
|
|
tag_and_push_release_service.tag_release(repo.get_release())
|
|
|
|
|
|
|
|
|
|
assert 'v123.124.0\n' in git_api.get_latest_tag()
|
|
|
|
|