From ebe6b60aaf9cbc4ace1368a38e62c8a591df6b2c Mon Sep 17 00:00:00 2001 From: Derek DeJonghe Date: Mon, 15 Jun 2020 16:45:34 -0400 Subject: [PATCH] update tests --- semver/get_version.py | 1 + semver/tests.py | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/semver/get_version.py b/semver/get_version.py index e4d0663..4bb7f07 100644 --- a/semver/get_version.py +++ b/semver/get_version.py @@ -57,3 +57,4 @@ def main(): if __name__ == '__main__': try: main() except: raise + diff --git a/semver/tests.py b/semver/tests.py index a391131..b32f0ec 100644 --- a/semver/tests.py +++ b/semver/tests.py @@ -1,7 +1,7 @@ import unittest, os, subprocess, re, semver from semver.logger import logging, logger, console_logger -from semver import get_version, NO_MERGE_FOUND, GET_COMMIT_MESSAGE +from semver import get_version, utils, NO_MERGE_FOUND, GET_COMMIT_MESSAGE config_data = """ [bumpversion] @@ -54,13 +54,23 @@ class TestGetVersion(unittest.TestCase): def test_branch_dotting(self): create_git_environment() subprocess.call(['git', 'checkout', '-b', 'test/branch']) - branch = get_version.get_version(True) + branch = get_version.get_version(dot=True) self.assertEqual(branch, "test.branch") def test_branch_dotting_false(self): create_git_environment() subprocess.call(['git', 'checkout', '-b', 'test/branch']) - branch = get_version.get_version(False) + branch = get_version.get_version(dot=False) self.assertEqual(branch, "test/branch") + def test_branch_npm_pre_release(self): + create_git_environment() + subprocess.call(['git', 'checkout', '-b', 'test/branch']) + branch = get_version.get_version(version_format='npm') + self.assertEqual(branch, "0.0.0-test-branch.0") + def test_branch_maven_pre_release(self): + create_git_environment() + subprocess.call(['git', 'checkout', '-b', 'test/branch']) + branch = get_version.get_version(version_format='npm') + self.assertEqual(branch, "0.0.0-test-branch-SNAPSHOT") def test_get_version_run(self): create_git_environment() val = subprocess.Popen(['python', '../get_version.py', '-d'], stdout=subprocess.PIPE, @@ -72,7 +82,7 @@ class TestGetTagVersion(unittest.TestCase): def test_get_version_tag(self): create_git_environment() subprocess.call(['git', 'tag', '1.0.0']) - tag = get_version.get_tag_version() + tag = utils.get_tag_version() self.assertEqual(tag, "1.0.0") def test_get_version_multiple(self): create_git_environment() @@ -87,7 +97,7 @@ class TestGetTagVersion(unittest.TestCase): subprocess.call(['git', 'tag', '1.1.0']) subprocess.call(['git', 'tag', '1.2.0']) subprocess.call(['git', 'tag', '1.2.1']) - tag = get_version.get_tag_version() + tag = utils.get_tag_version() self.assertEqual(tag, "1.2.1") def test_get_version_out_of_order(self): subprocess.call(['git', 'tag', '0.1.0']) @@ -101,11 +111,11 @@ class TestGetTagVersion(unittest.TestCase): subprocess.call(['git', 'tag', '1.1.7']) subprocess.call(['git', 'tag', '1.2.0']) subprocess.call(['git', 'tag', '0.2.1']) - tag = get_version.get_tag_version() + tag = utils.get_tag_version() self.assertEqual(tag, "8.1.0") def test_default_get_version_tag(self): create_git_environment() - tag = get_version.get_tag_version() + tag = utils.get_tag_version() self.assertEqual(tag, "0.0.0") class TestGetCommitMessageRegex(unittest.TestCase): @@ -145,4 +155,4 @@ if __name__ == "__main__": with open('.bumpversion.cfg', "w") as config: config.write(config_data) unittest.main() - os.chdir("..") \ No newline at end of file + os.chdir("..")