dda-devops-build/test/test_services.py

41 lines
1.1 KiB
Python
Raw Normal View History

2023-02-22 09:58:27 +00:00
from pathlib import Path
import sys
import os
# getting the name of the directory
# where the this file is present.
current = os.path.dirname(os.path.realpath(__file__))
# Getting the parent directory name
# where the current directory is present.
parent = os.path.dirname(current)
# adding the parent directory to
# the sys.path.
sys.path.append(parent)
# now we can import the module in the parent
# directory.
from services import InitReleaseService
2023-02-24 09:31:04 +00:00
from domain import ReleaseType
from infrastructure import VersionRepository
2023-02-22 09:58:27 +00:00
def test_init_release_service(tmp_path):
# init
file_name = 'config.json'
with open(f'test/resources/{file_name}', 'r') as gradle_file:
contents = gradle_file.read()
f = tmp_path / file_name
f.write_text(contents)
repo = VersionRepository(f)
release_service = InitReleaseService(repo)
version = release_service.create_release_version(commit_string='Release MINOR')
2023-02-22 09:58:27 +00:00
assert "123.124.0" in version.get_version_string()
2023-02-22 09:58:27 +00:00
2023-02-22 11:05:02 +00:00
version = version.create_bump_version()
2023-02-22 09:58:27 +00:00
2023-02-22 11:05:02 +00:00
assert "123.124.1-SNAPSHOT" in version.get_version_string()