|
4 | 4 | import anys |
5 | 5 | import click |
6 | 6 | from click import testing |
| 7 | +from opentelemetry.sdk.trace import id_generator |
7 | 8 | import pytest |
8 | 9 |
|
9 | 10 | from mergify_cli.ci import cli as cli_junit_upload |
@@ -310,3 +311,46 @@ def test_junit_file_not_found_error_message() -> None: |
310 | 311 | assert ( |
311 | 312 | "check if your test execution step completed successfully" in result.output |
312 | 313 | ) |
| 314 | + |
| 315 | + |
| 316 | +async def test_process_junit_file_reporting( |
| 317 | + capsys: pytest.CaptureFixture[str], |
| 318 | +) -> None: |
| 319 | + with ( |
| 320 | + mock.patch.object( |
| 321 | + quarantine, |
| 322 | + "check_and_update_failing_spans", |
| 323 | + return_value=0, |
| 324 | + ), |
| 325 | + mock.patch.object(upload, "upload"), |
| 326 | + mock.patch.object( |
| 327 | + id_generator.RandomIdGenerator, |
| 328 | + "generate_span_id", |
| 329 | + return_value=12345678910, |
| 330 | + ), |
| 331 | + pytest.raises(SystemExit), |
| 332 | + ): |
| 333 | + await cli_junit_upload._process_junit_files( |
| 334 | + api_url="https://api.mergify.com", |
| 335 | + token="foobar", # noqa: S106 |
| 336 | + repository="foo/bar", |
| 337 | + test_framework=None, |
| 338 | + test_language=None, |
| 339 | + tests_target_branch="main", |
| 340 | + files=(str(REPORT_XML),), |
| 341 | + ) |
| 342 | + |
| 343 | + captured = capsys.readouterr() |
| 344 | + assert ( |
| 345 | + captured.out |
| 346 | + == """🚀 CI Insights · Upload JUnit |
| 347 | +──────────────────────────── |
| 348 | +📂 Discovered reports: 1 |
| 349 | +🛠️ MERGIFY_TEST_RUN_ID=00000002dfdc1c3e |
| 350 | +🧪 Parsed tests: 2 (✅ passed: 1 | ❌ failed: 1) |
| 351 | +
|
| 352 | +🎉 Verdict |
| 353 | +• Status: ✅ OK — all 1 failures are quarantined (ignored for CI status) |
| 354 | +• Exit code: 0 |
| 355 | +""" |
| 356 | + ) |
0 commit comments