Skip to content

Commit

Permalink
fix: use console print instead of log for annotation (#565)
Browse files Browse the repository at this point in the history
`console.log` may wrap or add some whitespaces at end of the annotation.
  • Loading branch information
lecrepont01 authored Dec 2, 2024
1 parent a2a7e2d commit 18ea280
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion mergify_cli/ci/junit_upload.py
Original file line number Diff line number Diff line change
@@ -78,5 +78,8 @@ async def upload( # noqa: PLR0913, PLR0917
)

gigid = response.json()["gigid"]
console.log(f"::notice title=CI Issues report::CI_ISSUE_GIGID={gigid}")
console.print(
f"::notice title=CI Issues report::CI_ISSUE_GIGID={gigid}",
soft_wrap=True,
)
console.log("[green]:tada: File(s) uploaded[/]")
14 changes: 12 additions & 2 deletions mergify_cli/tests/ci_issues/test_junit_upload.py
Original file line number Diff line number Diff line change
@@ -131,12 +131,16 @@ def test_get_files_to_upload() -> None:
assert files_to_upload[0][1][1].closed


async def test_junit_upload(respx_mock: respx.MockRouter) -> None:
async def test_junit_upload(
respx_mock: respx.MockRouter,
capsys: pytest.CaptureFixture[str],
) -> None:
gigid = "eyJjaV9qb2JfaWQiOjcwNzQyLCJzaWduYXR1cmUiOiI2NjcxN2QwZDdiZjZkMzAxMmFmNGE4NWQ1YTFlZDhmYjNkNDBjYmM4MmZjZjgxZTVmNzEzNzEyZjRlZjIxOTFmIn0="
respx_mock.post(
"/v1/repos/user/repo/ci_issues_upload",
).respond(
200,
json={"gigid": "1234azertyuiop"},
json={"gigid": gigid},
)

await junit_upload_mod.upload(
@@ -149,6 +153,12 @@ async def test_junit_upload(respx_mock: respx.MockRouter) -> None:
(str(REPORT_XML),),
)

captured = capsys.readouterr()
assert (
captured.out.split("\n")[0]
== f"::notice title=CI Issues report::CI_ISSUE_GIGID={gigid}"
)


async def test_junit_upload_http_error(respx_mock: respx.MockRouter) -> None:
respx_mock.post("/v1/repos/user/repo/ci_issues_upload").respond(

0 comments on commit 18ea280

Please sign in to comment.