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 from release_mixin import ReleaseMixin, create_release_mixin_config
MAIN_BRANCH = 'main' MAIN_BRANCH = 'main'
STAGE = 'test'
PROJECT_ROOT_PATH = '.'
MODULE = 'test'
BUILD_DIR_NAME = "build_dir"
class MyBuild(ReleaseMixin): class MyBuild(ReleaseMixin):
pass pass
@ -31,11 +34,16 @@ class MyBuild(ReleaseMixin):
def initialize(project, CONFIG_FILE): def initialize(project, CONFIG_FILE):
project.build_depends_on('ddadevops>=3.1.2') project.build_depends_on('ddadevops>=3.1.2')
config = create_release_mixin_config(CONFIG_FILE, MAIN_BRANCH) 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) build = MyBuild(project, config)
return build return build
def test_release_mixin(tmp_path): def test_release_mixin(tmp_path):
#init
with open(f'test/resources/config.json', 'r') as json_file: with open(f'test/resources/config.json', 'r') as json_file:
contents = json_file.read() contents = json_file.read()
@ -47,10 +55,15 @@ def test_release_mixin(tmp_path):
# init # init
build = initialize(project, CONFIG_FILE) build = initialize(project, CONFIG_FILE)
build.commit_string = "MAJOR bla"
build.init() build.init()
release_version = build.release_version release_version = build.release_version
# test
assert "124.0.0" in release_version.get_version_string()
# init
bump_version = build.bump_version bump_version = build.bump_version
# test # test
assert "123.124.0" in release_version.get_version_string() assert "124.0.1-SNAPSHOT" in bump_version.get_version_string()
assert "123.124.1-SNAPSHOT" in bump_version.get_version_string()