//! Invariant: MCP audit handler returns structured JSON payload.
#![allow(dead_code)]

// `tools` references `crate::settings` (import gate); mirror lib.rs layout for #[path] compile.
#[path = "../src/settings.rs"]
mod settings;

#[path = "../src/tools/mod.rs"]
mod tools;

#[tokio::test]
async fn audit_handler_returns_structured_payload() {
    let result = tools::audit::execute(tools::audit::AuditParams {
        limit: 5,
        query: None,
        event_type: None,
    })
    .await
    .expect("Fix: envseal_audit MCP handler should execute successfully");

    let count = result
        .get("count")
        .and_then(serde_json::Value::as_u64)
        .expect("Fix: envseal_audit response must include numeric 'count'");
    let entries = result
        .get("entries")
        .and_then(serde_json::Value::as_array)
        .expect("Fix: envseal_audit response must include array 'entries'");

    assert_eq!(
        count as usize,
        entries.len(),
        "Fix: envseal_audit response should keep entries/count structurally consistent"
    );
}
