2023-02-24 09:31:04 +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.
|
|
|
|
|
2023-03-02 15:07:13 +00:00
|
|
|
from domain import Version, ReleaseType, Release
|
2023-02-24 09:31:04 +00:00
|
|
|
|
2023-03-02 15:07:13 +00:00
|
|
|
def test_version(tmp_path: Path):
|
2023-02-28 12:25:47 +00:00
|
|
|
version = Version(tmp_path, [1, 2, 3])
|
2023-02-24 09:31:04 +00:00
|
|
|
version.increment(ReleaseType.SNAPSHOT)
|
|
|
|
assert version.get_version_string() == "1.2.3-SNAPSHOT"
|
|
|
|
assert version.version_list == [1, 2, 3]
|
|
|
|
assert version.is_snapshot
|
|
|
|
|
2023-02-28 12:25:47 +00:00
|
|
|
version = Version(tmp_path, [1, 2, 3])
|
2023-02-24 09:31:04 +00:00
|
|
|
version.increment(ReleaseType.BUMP)
|
|
|
|
assert version.get_version_string() == "1.2.4-SNAPSHOT"
|
|
|
|
assert version.version_list == [1, 2, 4]
|
|
|
|
assert version.is_snapshot
|
|
|
|
|
2023-02-28 12:25:47 +00:00
|
|
|
version = Version(tmp_path, [1, 2, 3])
|
2023-02-24 09:31:04 +00:00
|
|
|
version.increment(ReleaseType.PATCH)
|
|
|
|
assert version.get_version_string() == "1.2.4"
|
|
|
|
assert version.version_list == [1, 2, 4]
|
|
|
|
assert not version.is_snapshot
|
|
|
|
|
2023-02-28 12:25:47 +00:00
|
|
|
version = Version(tmp_path, [1, 2, 3])
|
2023-02-24 09:31:04 +00:00
|
|
|
version.increment(ReleaseType.MINOR)
|
|
|
|
assert version.get_version_string() == "1.3.0"
|
|
|
|
assert version.version_list == [1, 3, 0]
|
|
|
|
assert not version.is_snapshot
|
|
|
|
|
2023-02-28 12:25:47 +00:00
|
|
|
version = Version(tmp_path, [1, 2, 3])
|
2023-02-24 09:31:04 +00:00
|
|
|
version.increment(ReleaseType.MAJOR)
|
|
|
|
assert version.get_version_string() == "2.0.0"
|
|
|
|
assert version.version_list == [2, 0, 0]
|
|
|
|
assert not version.is_snapshot
|
2023-03-02 15:07:13 +00:00
|
|
|
|
|
|
|
def test_release(tmp_path):
|
|
|
|
version = Version(tmp_path, [1, 2, 3])
|
|
|
|
release = Release(ReleaseType.MINOR, version, "main")
|
|
|
|
|
|
|
|
release_version = release.release_version()
|
|
|
|
assert release_version.get_version_string() in '1.3.0'
|
|
|
|
|
|
|
|
bump_version = release.bump_version()
|
|
|
|
assert bump_version.get_version_string() in "1.3.1-SNAPSHOT"
|