*** Settings ***
Documentation     Smoke tests for resource registry migration (schema creation).
...               Validates that ``init_database`` creates the ``resource_types``,
...               ``resources``, and ``resource_edges`` tables with expected columns
...               and that the operation is idempotent.
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_resource_registry_migration.py

*** Test Cases ***
Schema Creation Produces Resource Registry Tables
    [Documentation]    Verify init_database creates resource_types, resources, and resource_edges tables
    [Tags]    database    migration    smoke
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    schema-creates-tables    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    schema-creates-tables-ok

Resource Registry Tables Have Expected Columns
    [Documentation]    Verify core columns exist on each resource registry table after migration
    [Tags]    database    migration    smoke
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    table-columns    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    table-columns-ok

Migration Is Idempotent
    [Documentation]    Verify that running init_database twice does not raise errors
    [Tags]    database    migration    smoke
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    migration-idempotent    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    migration-idempotent-ok
