*** Settings ***
Documentation    Integration tests for ResourceHandler content_hash method
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Content Hash Is Deterministic
    [Documentation]    Same file content produces same hash on repeated calls
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    deterministic    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    deterministic-ok

Empty Resource Returns Sentinel Hash
    [Documentation]    Missing resource returns EMPTY_CONTENT_HASH sentinel
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    empty-sentinel    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    empty-sentinel-ok

Content Change Detected By Hash
    [Documentation]    Hash changes when file content is modified
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    content-change-detection    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    content-change-detection-ok

Configurable Hash Algorithm
    [Documentation]    SHA-256 and MD5 produce different-length hashes
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    configurable-algorithm    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    configurable-algorithm-ok

FsDirectory Recursive Hash
    [Documentation]    FsDirectoryHandler hashes directory contents recursively
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    fs-directory-recursive    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    fs-directory-recursive-ok
