*** Settings ***
Resource          flow_zmx.resource
Resource          res_zmx.resource
Library           DateTime

*** Variables ***
${path}           /api/v1/plan/update_trigger

*** Test Cases ***
正例-正常更新计划触发器
    [Tags]    F
    create session    URI    ${URL}
    ${current_time}    Get Current Date
    ${future_time}    Add Time To Date    ${current_time}    30 days
    ${formatted_timec}    Convert Date    ${current_time}    result_format=%Y-%m-%dT%H:%M:%S
    ${formatted_timef}    Convert Date    ${future_time}    result_format=%Y-%m-%dT%H:%M:%S
    ${content}    POST请求结果    ${path}    {"type":"定时触发器","trigger_type":"cron","expression":"0 9 * * *","start_time":"${formatted_timec}","end_time":"${formatted_timef}","is_active":true,"plan_id":${plan_id},"trigger_id":${trigger_id}}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200
    Should Be Equal As Strings    ${content["data"]}    ${trigger_id}

反例-不传入token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"type":"定时触发器","trigger_type":"cron","expression":"0 9 * * *","start_time":"2025-09-05T00:00:00","end_time":"2025-10-05T00:00:00","is_active":true,"plan_id":${plan_id},"trigger_id":${trigger_id}}    401    ${EMPTY}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-传入空白token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"type":"定时触发器","trigger_type":"cron","expression":"0 9 * * *","start_time":"2025-09-05T00:00:00","end_time":"2025-10-05T00:00:00","is_active":true,"plan_id":${plan_id},"trigger_id":${trigger_id}}    401    {}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-不传入plan_id参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"type":"定时触发器","trigger_type":"cron","expression":"0 9 * * *","start_time":"2025-09-05T00:00:00","end_time":"2025-10-05T00:00:00","is_active":true,"trigger_id":${trigger_id}}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["type"]}    missing

反例-不传入trigger_id参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"type":"定时触发器","trigger_type":"cron","expression":"0 9 * * *","start_time":"2025-09-05T00:00:00","end_time":"2025-10-05T00:00:00","is_active":true,"plan_id":${plan_id}}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["type"]}    missing
