terraformDummyRepo/test/test_git_handler.py

65 lines
1.6 KiB
Python
Raw Normal View History

2023-02-21 14:08:39 +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-02-22 09:25:21 +00:00
from git_repository import *
from release_type import ReleaseType
2023-02-21 14:08:39 +00:00
2023-02-22 09:25:21 +00:00
def test_git_repository():
2023-02-21 14:08:39 +00:00
# init
2023-02-22 09:25:21 +00:00
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()
2023-02-21 14:08:39 +00:00
#test
2023-02-22 09:25:21 +00:00
assert release_type == None