*** Settings ***
Documentation       Repository Indexing CLI Integration Tests
Library             Process
Library             OperatingSystem

*** Variables ***
${PYTHON}           python
${HELPER}           ${CURDIR}/helper_repo_indexing_cli.py

*** Test Cases ***
E2E Add Resource Index And Check Status
    [Documentation]    End-to-end: add resource, index it, check status
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    e2e
    ...    on_timeout=kill    timeout=60s
    Should Be Equal As Integers    ${result.rc}    0    E2E test failed: ${result.stderr}
    Should Contain    ${result.stdout}    E2E add-index-status PASSED

Incremental Reindex After File Change
    [Documentation]    Incremental re-index detects new files
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    incremental
    ...    on_timeout=kill    timeout=60s
    Should Be Equal As Integers    ${result.rc}    0    Incremental test failed: ${result.stderr}
    Should Contain    ${result.stdout}    Incremental reindex PASSED

Full Reindex Replaces Entire Index
    [Documentation]    Full re-index replaces the entire index
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    full
    ...    on_timeout=kill    timeout=60s
    Should Be Equal As Integers    ${result.rc}    0    Full reindex test failed: ${result.stderr}
    Should Contain    ${result.stdout}    Full reindex PASSED

Status Returns None When No Index Exists
    [Documentation]    Status check with no index returns None
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    no-index
    ...    on_timeout=kill    timeout=60s
    Should Be Equal As Integers    ${result.rc}    0    Status no-index test failed: ${result.stderr}
    Should Contain    ${result.stdout}    Status no-index PASSED

Remove Index Cleans Up All Data
    [Documentation]    Removing an index cleans up all data
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    remove
    ...    on_timeout=kill    timeout=60s
    Should Be Equal As Integers    ${result.rc}    0    Remove index test failed: ${result.stderr}
    Should Contain    ${result.stdout}    Remove index PASSED

*** Keywords ***
