From ac8f3d6ab9bfb976d00b7890d35cfe9be3354114 Mon Sep 17 00:00:00 2001 From: David Fernandez Date: Mon, 15 Apr 2024 15:05:39 +0100 Subject: [PATCH] [OPT-1125] supfix tests. --- .../startleft/_version/version_scheme.py | 2 ++ .../tests/unit/_version/test_local_scheme.py | 4 ++++ .../unit/_version/test_version_scheme.py | 7 +++++++ .../tests/unit/_version/version_mocks.py | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/startleft/startleft/_version/version_scheme.py b/startleft/startleft/_version/version_scheme.py index 54ed8c41..acda277b 100644 --- a/startleft/startleft/_version/version_scheme.py +++ b/startleft/startleft/_version/version_scheme.py @@ -20,6 +20,8 @@ def choose_strategy_by_branch(branch_name: str, exact: bool) -> callable: return _tag_version_strategy elif 'hotfix/' in branch_name: return _patch_version_dev_commit_strategy + elif 'supfix/' in branch_name: + return _patch_version_dev_commit_strategy elif 'bugfix' in branch_name: return _tag_version_dev_commit_strategy else: diff --git a/startleft/tests/unit/_version/test_local_scheme.py b/startleft/tests/unit/_version/test_local_scheme.py index a7e901fb..3d802b91 100644 --- a/startleft/tests/unit/_version/test_local_scheme.py +++ b/startleft/tests/unit/_version/test_local_scheme.py @@ -15,6 +15,8 @@ class TestLocalScheme: ('hotfix/XXX-000', '_node_strategy'), ('release/1.5.0', '_no_local_version_strategy'), ('bugfix/XXX-000', '_node_strategy'), + ('support/1.19', '_no_local_version_strategy'), + ('supfix/XXX-000', '_node_strategy'), ('dev', '_node_strategy'), ('feature/XXX-000', '_node_strategy'), ('UNKNOWN_BRANCH_PATTERN', '_node_strategy'), @@ -38,6 +40,8 @@ def test_strategy_by_branch(self, branch, expected_strategy): param(RELEASE_VERSION_BUGFIX, '', id='test_release_version_bugfix'), # BUGFIX param(BUGFIX_VERSION, '+g6cda015', id='test_bugfix_version'), + # SUPFIX + param(SUPFIX_VERSION, '+g6cda015', id='test_supfix_version'), # DEV param(DEV_RTP_VERSION, '+g17d9f68', id='test_dev_rtp_version'), param(DEV_RP_VERSION, '+g3e49113', id='test_dev_rp_version'), diff --git a/startleft/tests/unit/_version/test_version_scheme.py b/startleft/tests/unit/_version/test_version_scheme.py index f2a22a37..ac2f0d81 100644 --- a/startleft/tests/unit/_version/test_version_scheme.py +++ b/startleft/tests/unit/_version/test_version_scheme.py @@ -20,6 +20,8 @@ class TestVersionScheme: ('main', '_tag_version_strategy'), ('hotfix/XXX-000', '_patch_version_dev_commit_strategy'), ('release/1.5.0', '_tag_version_strategy'), + ('support/1.19', '_tag_version_strategy'), + ('supfix/XXX-000', '_patch_version_dev_commit_strategy'), ('bugfix/XXX-000', '_tag_version_dev_commit_strategy'), ('dev', '_minor_version_dev_commit_strategy'), ('feature/XXX-000', '_minor_version_dev_commit_strategy'), @@ -60,6 +62,11 @@ def test_detached_head(self, exact: bool, expected_strategy): param(RELEASE_VERSION_BUGFIX, '1.6.0rc1', id='test_release_version_bugfix'), # BUGFIX param(BUGFIX_VERSION, '1.6.0rc1.dev1', id='test_bugfix_version'), + # SUPPORT + param(SUPPORT_VERSION_NO_SUPFIX, '1.19.0', id='test_support_version_no_supfix'), + param(SUPPORT_VERSION_SUPFIX, '1.19.1', id='test_support_version_supfix'), + # SUPFIX + param(SUPFIX_VERSION, '1.19.1.dev1', id='test_supfix_version'), # DEV param(DEV_RTP_VERSION, '1.7.0.dev19', id='test_dev_rtp_version'), param(DEV_RTP_NO_DISTANCE_VERSION, '1.7.0', id='test_dev_rtp_no_distance_version'), diff --git a/startleft/tests/unit/_version/version_mocks.py b/startleft/tests/unit/_version/version_mocks.py index b34b1ce2..b905d039 100644 --- a/startleft/tests/unit/_version/version_mocks.py +++ b/startleft/tests/unit/_version/version_mocks.py @@ -38,6 +38,25 @@ BUGFIX_VERSION = Mock( branch='bugfix/XXX-000', tag='1.6.0rc1', distance=1, exact=False, node='g6cda015') + +########### +# SUPPORT # +########### + +SUPPORT_VERSION_NO_SUPFIX = Mock( + branch='support/1.19', tag='1.19.0', distance=None, exact=True, node='g05febfb' +) + +SUPPORT_VERSION_SUPFIX = Mock( + branch='support/1.19', tag='1.19.1', distance=3, exact=False, node='ga1d748e' +) + +########## +# SUPFIX # +########## +SUPFIX_VERSION = Mock( + branch='supfix/XXX-000', tag='1.19.0', distance=1, exact=False, node='g6cda015') + ####### # DEV # #######