relate-executor 1.5.0

In-memory graph and Cypher physical executor
Documentation
//! Shared test helpers for the `procedure_rows` test modules (`mod.rs` and
//! the family modules): run a built-in procedure against a graph and
//! compare its rows.

use std::collections::BTreeMap;

use relate_core::Value;

use super::{builtin_procedure_rows, executable_signature};
use crate::graph::Graph;
use crate::overlay::ExecGraph;

pub(super) fn string(value: &str) -> Value {
    Value::String(value.into())
}

/// The `dbms.listCapabilities` rows' name column, in listing order —
/// the capability tests' shared read (the twin of the facade suites'
/// `first_column_strings`).
pub(super) fn capability_names(rows: &[BTreeMap<String, Value>]) -> Vec<&str> {
    rows.iter()
        .map(|row| {
            row["name"]
                .as_string()
                .expect("every capability row names itself")
        })
        .collect()
}

pub(super) fn rows(graph: &Graph, name: &str) -> Vec<BTreeMap<String, Value>> {
    rows_with_principal(graph, name, None)
}

pub(super) fn rows_with_principal(
    graph: &Graph,
    name: &str,
    principal: Option<&str>,
) -> Vec<BTreeMap<String, Value>> {
    rows_with_args(graph, name, principal, &BTreeMap::new())
}

pub(super) fn rows_with_args(
    graph: &Graph,
    name: &str,
    principal: Option<&str>,
    args: &BTreeMap<String, Value>,
) -> Vec<BTreeMap<String, Value>> {
    let view = ExecGraph::read(graph);
    let signature = executable_signature(name).expect("schema procedure is a registered builtin");
    builtin_procedure_rows(&view, signature, principal, args)
        .expect("schema procedure's rows are produced without error")
}