use std::path::Path;
use trusty_common::descriptor_source;
use trusty_common::docgen::{assert_region, count_note, render_tool_section, tool_rows};
use trusty_memory::tools::{tool_definitions, tool_definitions_with};
const REGION: &str = "mcp-tools";
const REGEN: &str = "UPDATE_DOCS=1 cargo test -p trusty-memory --test generated_docs";
fn section() -> String {
let rows = tool_rows(&tool_definitions()).expect("descriptor shape");
render_tool_section(
&descriptor_source!(trusty_memory::tools::tool_definitions),
&count_note(&[("", rows.len())]),
&rows,
)
}
#[test]
fn default_palace_variant_does_not_change_the_documented_roster() {
let roster = |v: &serde_json::Value| -> Vec<(String, String)> {
tool_rows(v)
.expect("rows")
.into_iter()
.map(|r| (r.name, r.summary))
.collect()
};
let base = roster(&tool_definitions());
for has_default in [false, true] {
assert_eq!(
base,
roster(&tool_definitions_with(has_default)),
"has_default={has_default} changed the documented roster"
);
}
assert_eq!(tool_definitions(), tool_definitions_with(false));
}
#[test]
fn readme_mcp_tool_section_is_generated() {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("README.md");
assert_region(&path, REGION, §ion(), REGEN);
}