From ac564ade7ecc55012b28ce9d9ece7166ef2032be Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 22 Feb 2023 10:25:21 +0100 Subject: [PATCH] Update tests for git handler --- test/test_git_handler.py | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/test/test_git_handler.py b/test/test_git_handler.py index 77d95c9..5623bc1 100644 --- a/test/test_git_handler.py +++ b/test/test_git_handler.py @@ -17,14 +17,48 @@ sys.path.append(parent) # now we can import the module in the parent # directory. -from git_handler import * +from git_repository import * +from release_type import ReleaseType -def test_git_handler(): +def test_git_repository(): # init - repo = GitRepo() - repo.get_commits() + 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 type(repo.commits) == dict - assert repo.commits["decd36b"] == ["(tag:refs/tags/TEST)", "Initial commit"] + 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