*** Settings ***
Documentation    Bug #968 / Issue #6325 — plan explain must reject plan_id, accept only decision_id
...              Integration tests verifying that ``plan explain <plan_id>`` is correctly
...              rejected with rc=1.  The old list_decisions fallback has been removed.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment With Database Isolation
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_tdd_plan_explain_plan_id.py

*** Test Cases ***
TDD Plan Explain Rejects Plan ID With RC 1
    [Documentation]    Verify that ``plan explain <plan_id>`` exits with rc=1
    ...                when given a plan ID (not a decision ID).
    ...                Issue #6325: the fallback to list_decisions has been removed.
    [Tags]  tdd_issue    tdd_issue_968    tdd_issue_4178
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    explain-with-plan-id    cwd=${WORKSPACE}    timeout=180s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-plan-explain-plan-id-rejected

TDD Plan Explain With Plan ID Shows Error Message
    [Documentation]    Verify that the output when given a plan_id contains
    ...                "not found" per the spec-compliant error message.
    [Tags]  tdd_issue    tdd_issue_968    tdd_issue_4178
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    explain-plan-id-shows-error    cwd=${WORKSPACE}    timeout=180s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-plan-explain-plan-id-error-ok
