update tests
This commit is contained in:
parent
2c07ef743e
commit
ebe6b60aaf
@ -57,3 +57,4 @@ def main():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try: main()
|
try: main()
|
||||||
except: raise
|
except: raise
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import unittest, os, subprocess, re, semver
|
import unittest, os, subprocess, re, semver
|
||||||
from semver.logger import logging, logger, console_logger
|
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 = """
|
config_data = """
|
||||||
[bumpversion]
|
[bumpversion]
|
||||||
@ -54,13 +54,23 @@ class TestGetVersion(unittest.TestCase):
|
|||||||
def test_branch_dotting(self):
|
def test_branch_dotting(self):
|
||||||
create_git_environment()
|
create_git_environment()
|
||||||
subprocess.call(['git', 'checkout', '-b', 'test/branch'])
|
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")
|
self.assertEqual(branch, "test.branch")
|
||||||
def test_branch_dotting_false(self):
|
def test_branch_dotting_false(self):
|
||||||
create_git_environment()
|
create_git_environment()
|
||||||
subprocess.call(['git', 'checkout', '-b', 'test/branch'])
|
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")
|
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):
|
def test_get_version_run(self):
|
||||||
create_git_environment()
|
create_git_environment()
|
||||||
val = subprocess.Popen(['python', '../get_version.py', '-d'], stdout=subprocess.PIPE,
|
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):
|
def test_get_version_tag(self):
|
||||||
create_git_environment()
|
create_git_environment()
|
||||||
subprocess.call(['git', 'tag', '1.0.0'])
|
subprocess.call(['git', 'tag', '1.0.0'])
|
||||||
tag = get_version.get_tag_version()
|
tag = utils.get_tag_version()
|
||||||
self.assertEqual(tag, "1.0.0")
|
self.assertEqual(tag, "1.0.0")
|
||||||
def test_get_version_multiple(self):
|
def test_get_version_multiple(self):
|
||||||
create_git_environment()
|
create_git_environment()
|
||||||
@ -87,7 +97,7 @@ class TestGetTagVersion(unittest.TestCase):
|
|||||||
subprocess.call(['git', 'tag', '1.1.0'])
|
subprocess.call(['git', 'tag', '1.1.0'])
|
||||||
subprocess.call(['git', 'tag', '1.2.0'])
|
subprocess.call(['git', 'tag', '1.2.0'])
|
||||||
subprocess.call(['git', 'tag', '1.2.1'])
|
subprocess.call(['git', 'tag', '1.2.1'])
|
||||||
tag = get_version.get_tag_version()
|
tag = utils.get_tag_version()
|
||||||
self.assertEqual(tag, "1.2.1")
|
self.assertEqual(tag, "1.2.1")
|
||||||
def test_get_version_out_of_order(self):
|
def test_get_version_out_of_order(self):
|
||||||
subprocess.call(['git', 'tag', '0.1.0'])
|
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.1.7'])
|
||||||
subprocess.call(['git', 'tag', '1.2.0'])
|
subprocess.call(['git', 'tag', '1.2.0'])
|
||||||
subprocess.call(['git', 'tag', '0.2.1'])
|
subprocess.call(['git', 'tag', '0.2.1'])
|
||||||
tag = get_version.get_tag_version()
|
tag = utils.get_tag_version()
|
||||||
self.assertEqual(tag, "8.1.0")
|
self.assertEqual(tag, "8.1.0")
|
||||||
def test_default_get_version_tag(self):
|
def test_default_get_version_tag(self):
|
||||||
create_git_environment()
|
create_git_environment()
|
||||||
tag = get_version.get_tag_version()
|
tag = utils.get_tag_version()
|
||||||
self.assertEqual(tag, "0.0.0")
|
self.assertEqual(tag, "0.0.0")
|
||||||
|
|
||||||
class TestGetCommitMessageRegex(unittest.TestCase):
|
class TestGetCommitMessageRegex(unittest.TestCase):
|
||||||
@ -145,4 +155,4 @@ if __name__ == "__main__":
|
|||||||
with open('.bumpversion.cfg', "w") as config:
|
with open('.bumpversion.cfg', "w") as config:
|
||||||
config.write(config_data)
|
config.write(config_data)
|
||||||
unittest.main()
|
unittest.main()
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
Loading…
Reference in New Issue
Block a user