Create realistic test conditions

This commit is contained in:
erik 2023-02-22 16:19:36 +01:00
parent 99b8884d11
commit d759036989

View file

@ -23,7 +23,10 @@ from version import *
from release_mixin import ReleaseMixin, create_release_mixin_config
MAIN_BRANCH = 'main'
STAGE = 'test'
PROJECT_ROOT_PATH = '.'
MODULE = 'test'
BUILD_DIR_NAME = "build_dir"
class MyBuild(ReleaseMixin):
pass
@ -31,11 +34,16 @@ class MyBuild(ReleaseMixin):
def initialize(project, CONFIG_FILE):
project.build_depends_on('ddadevops>=3.1.2')
config = create_release_mixin_config(CONFIG_FILE, MAIN_BRANCH)
config.update({'stage': STAGE})
config.update({'module': MODULE})
config.update({'project_root_path': PROJECT_ROOT_PATH})
config.update({'build_dir_name': BUILD_DIR_NAME})
build = MyBuild(project, config)
return build
def test_release_mixin(tmp_path):
#init
with open(f'test/resources/config.json', 'r') as json_file:
contents = json_file.read()
@ -46,11 +54,16 @@ def test_release_mixin(tmp_path):
project = Project(base_dir)
# init
build = initialize(project, CONFIG_FILE)
build = initialize(project, CONFIG_FILE)
build.commit_string = "MAJOR bla"
build.init()
release_version = build.release_version
# test
assert "124.0.0" in release_version.get_version_string()
# init
bump_version = build.bump_version
# test
assert "123.124.0" in release_version.get_version_string()
assert "123.124.1-SNAPSHOT" in bump_version.get_version_string()
assert "124.0.1-SNAPSHOT" in bump_version.get_version_string()