Update tests for git handler

This commit is contained in:
erik 2023-02-22 10:25:21 +01:00
parent 0b3daf595a
commit ac564ade7e

View file

@ -17,14 +17,48 @@ sys.path.append(parent)
# now we can import the module in the parent # now we can import the module in the parent
# directory. # directory.
from git_handler import * from git_repository import *
from release_type import ReleaseType
def test_git_handler(): def test_git_repository():
# init # init
repo = GitRepo() commit_string = "Major bla"
repo.get_commits() 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 #test
assert type(repo.commits) == dict assert release_type == ReleaseType.MINOR
assert repo.commits["decd36b"] == ["(tag:refs/tags/TEST)", "Initial commit"]
# 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