Commit 1e25dd72 authored by Konstantinos Togias's avatar Konstantinos Togias
Browse files

fix: preserve source revision in GitLab acceptance links

parent bf0f2cf5
Loading
Loading
Loading
Loading
Loading
+5 −3
Changes for ansible/tests/unit/test_report_view.py: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ def test_every_selected_check_has_a_source_explanation_and_documentation_anchor(
            assert "### " + heading + "\n" in catalog


def test_actual_cases_keep_failures_skips_time_and_parameter_identity(tmp_path):
def test_actual_cases_keep_failures_skips_time_and_parameter_identity(tmp_path, monkeypatch):
    monkeypatch.setenv("CI_PROJECT_URL", "https://gitlab.example/oop/ansible")
    (tmp_path / "health").mkdir()
    raw = ('<testsuite><testcase name="test_keycloak_issuer_is_the_public_url[oop]" time="1.2">'
           '<system-out>original captured output</system-out></testcase>'
@@ -36,9 +37,9 @@ def test_actual_cases_keep_failures_skips_time_and_parameter_identity(tmp_path):
    path.write_text(raw)
    nodes = [node for _, _, nodes in PHASES for node in nodes]
    checks = observed_checks(path, nodes)
    write_acceptance_junit(tmp_path, checks, "platform-lab")
    write_acceptance_junit(tmp_path, checks, "platform-lab", "a" * 40)
    first = ET.parse(tmp_path / "acceptance-junit.xml").findall(".//testcase")
    write_acceptance_junit(tmp_path, checks, "platform-lab-helm")
    write_acceptance_junit(tmp_path, checks, "platform-lab-helm", "a" * 40)
    second = ET.parse(tmp_path / "acceptance-junit.xml").findall(".//testcase")
    assert path.read_text() == raw
    assert len({case.get("name") for case in first + second}) == 6
@@ -48,6 +49,7 @@ def test_actual_cases_keep_failures_skips_time_and_parameter_identity(tmp_path):
    assert first[0].find("system-out").text and first[0].get("file")
    assert "original captured output" in first[0].find("system-out").text
    assert len(first[0].findall("system-out")) == 1
    assert "/blob/" + "a" * 40 + "/ci/lab/CHECKS.md" in first[0].find("system-out").text


@pytest.mark.parametrize("passed", [True, False])
+3 −3
Changes for ci/report_view.py: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -48,10 +48,10 @@ def observed_checks(junit, nodes):


def write_acceptance_junit(output, checks, label, source=None):
    source = output / "health/junit.xml"
    if not source.is_file():
    junit = output / "health/junit.xml"
    if not junit.is_file():
        return
    document = ET.parse(source)
    document = ET.parse(junit)
    cases = document.findall(".//testcase")
    if len(cases) != len(checks):
        raise ValueError("Acceptance presentation must retain every observed case")