diff --git a/landoscript/src/landoscript/script.py b/landoscript/src/landoscript/script.py index 13a244166..d02bd0604 100644 --- a/landoscript/src/landoscript/script.py +++ b/landoscript/src/landoscript/script.py @@ -88,9 +88,11 @@ async def process_actions(session, context, owner, repo, public_artifact_dir, br if version_bump_actions: lando_actions.extend(version_bump_actions) elif action == "tag": - if "hg_repo_url" not in payload["tag_info"]: - raise TaskVerificationError("must provide hg_repo_url!") - tag_actions = await tag.run(session, tag.HgTagInfo(**payload["tag_info"])) + if "hg_repo_url" in payload["tag_info"]: + tag_info = tag.HgTagInfo(**payload["tag_info"]) + else: + tag_info = tag.GitTagInfo(**payload["tag_info"]) + tag_actions = await tag.run(session, tag_info) lando_actions.extend(tag_actions) elif action == "merge_day": merge_day_actions = await merge_day.run( diff --git a/landoscript/tests/test_tag.py b/landoscript/tests/test_tag.py index 41d454fbb..17a222cc1 100644 --- a/landoscript/tests/test_tag.py +++ b/landoscript/tests/test_tag.py @@ -59,30 +59,61 @@ def assert_func(req): @pytest.mark.asyncio -async def test_no_tags(aioresponses, github_installation_responses, context): +@pytest.mark.parametrize( + "tag_info,dry_run", + ( + pytest.param( + { + "revision": "ghijkl654321", + "tags": ["BUILD1"], + }, + True, + id="dry_run", + ), + pytest.param( + { + "revision": "ghijkl654321", + "tags": ["BUILD1"], + }, + False, + id="one_tag", + ), + pytest.param( + { + "revision": "ghijkl654321", + "tags": ["BUILD1", "RELEASE"], + }, + False, + id="multiple_tags", + ), + ), +) +async def test_success_git(aioresponses, github_installation_responses, context, tag_info, dry_run): payload = { "actions": ["tag"], "lando_repo": "repo_name", - "tag_info": { - "revision": "abcdef123456", - "hg_repo_url": "https://hg.testing/repo", - "tags": [], - }, + "tag_info": tag_info, + "dry_run": dry_run, } - await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], err=TaskVerificationError, errmsg="must provide at least one tag!") + + def assert_func(req): + assert_tag_response(req, tag_info, tag_info["revision"]) + + await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], not dry_run, assert_func) @pytest.mark.asyncio -async def test_hg_repo_url(aioresponses, github_installation_responses, context): +async def test_no_tags(aioresponses, github_installation_responses, context): payload = { "actions": ["tag"], "lando_repo": "repo_name", "tag_info": { "revision": "abcdef123456", - "tags": ["FOO"], + "hg_repo_url": "https://hg.testing/repo", + "tags": [], }, } - await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], err=TaskVerificationError, errmsg="must provide hg_repo_url!") + await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], err=TaskVerificationError, errmsg="must provide at least one tag!") @pytest.mark.parametrize(