dda-devops-build/test/test_git_repository.py
2023-02-22 10:26:25 +01:00

64 lines
1.6 KiB
Python

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 git_repository import *
from release_type import ReleaseType
def test_git_repository():
# init
commit_string = "Major bla"
repo = GitRepository.create_from_commit_string(commit_string)
release_type = repo.get_release_type_from_latest_commit()
#test
assert release_type == ReleaseType.MAJOR
# init
commit_string = "MINOR bla"
repo = GitRepository.create_from_commit_string(commit_string)
release_type = repo.get_release_type_from_latest_commit()
#test
assert release_type == ReleaseType.MINOR
# init
commit_string = "PATCH bla"
repo = GitRepository.create_from_commit_string(commit_string)
release_type = repo.get_release_type_from_latest_commit()
# test
assert release_type == ReleaseType.PATCH
# init
commit_string = "SNAPSHOT bla"
repo = GitRepository.create_from_commit_string(commit_string)
release_type = repo.get_release_type_from_latest_commit()
#test
assert release_type == ReleaseType.SNAPSHOT
# init
commit_string = "bla"
repo = GitRepository.create_from_commit_string(commit_string)
release_type = repo.get_release_type_from_latest_commit()
#test
assert release_type == None