graphar-flight 0.1.2

Apache Arrow Flight SQL service over FalkorDB — Cypher in, Arrow out
Documentation
//! Wiring proof for graphar-flight's `functional_status` test-matrix surface
//! (the newest feature: the Flight SQL handlers report `get_flight_info` and
//! `do_get` health into the nornir matrix). The live call sites sit inside
//! async handlers that need a FalkorDB backend, so this exercises the crate's
//! public wrapper directly — the same forwarder those handlers call — and
//! asserts on the REAL emitted rows. Offline, in-process.
//!
//! One test per build (single test per binary → no race on the process-global
//! functional buffer `--features testmatrix` records into):
//!   * default build → the wrapper is a compiled-out no-op; assert it links.
//!   * `--features testmatrix` → assert the wrapper records the two Flight SQL
//!     surfaces with the correct green/red status/metric mapping.

/// Default build: `testmatrix` OFF → `functional_status` is an inlined no-op.
#[cfg(not(feature = "testmatrix"))]
#[test]
fn functional_status_is_a_linked_noop() {
    graphar_flight::functional_status(
        "graphar-flight/get_flight_info_statement",
        "schema_resolved",
        true,
        "MATCH (n) RETURN n",
    );
    graphar_flight::functional_status(
        "graphar-flight/do_get_statement",
        "cypher_stream",
        false,
        "bad cypher",
    );
}

/// `--features testmatrix`: the wrapper must forward each Flight SQL surface's
/// outcome into the matrix with the right status/metric mapping — mirroring the
/// real `get_flight_info_statement` (schema_resolved) and `do_get_statement`
/// (cypher_stream) call sites.
#[cfg(feature = "testmatrix")]
#[test]
fn wrapper_forwards_flight_sql_surface_outcomes() {
    use nornir_testmatrix::{drain_functional_rows, status};

    let _ = drain_functional_rows();

    // get_flight_info → schema resolved OK (green).
    graphar_flight::functional_status(
        "graphar-flight/get_flight_info_statement",
        "schema_resolved",
        true,
        "MATCH (n) RETURN n",
    );
    // do_get → cypher stream failed (red).
    graphar_flight::functional_status(
        "graphar-flight/do_get_statement",
        "cypher_stream",
        false,
        "MATCH (bad",
    );

    let rows = drain_functional_rows();

    let info = rows
        .iter()
        .find(|r| {
            r.suite == "graphar-flight/get_flight_info_statement"
                && r.test_name == "schema_resolved"
        })
        .unwrap_or_else(|| panic!("get_flight_info surface must record; got {rows:?}"));
    assert!(status::is_green(&info.status), "resolved schema is GREEN: {info:?}");
    assert_eq!(info.aspect, "functional");
    assert_eq!(info.metric, 0.0);
    assert_eq!(info.message, "MATCH (n) RETURN n", "detail carries the cypher");

    let get = rows
        .iter()
        .find(|r| r.suite == "graphar-flight/do_get_statement" && r.test_name == "cypher_stream")
        .unwrap_or_else(|| panic!("do_get surface must record; got {rows:?}"));
    assert!(status::is_red(&get.status), "a failed stream is RED: {get:?}");
    assert_eq!(get.metric, 1.0, "red rows carry metric 1.0");
    assert_eq!(get.message, "MATCH (bad", "detail carries the failing cypher");
}