use crate::config::{Local, TOOLS, read};
use std::path::{Path, PathBuf};
fn root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
}
fn example() -> String {
std::fs::read_to_string(root().join("docs").join("tools.example.json"))
.expect("the shipped example")
}
fn readme() -> String {
std::fs::read_to_string(root().join("README.md")).expect("the README")
}
#[test]
fn the_shipped_example_is_a_document_this_foot_reads() {
let set: Vec<Local> = read(Path::new(&root().join("docs").join("tools.example.json")))
.expect("the example is a document thrall reads");
assert_eq!(
set.len(),
3,
"a plain entry, a consenting one, and a bridged one"
);
assert!(!set[0].tool.subject_cwd, "the first entry is the plain one");
assert!(
set[1].tool.subject_cwd,
"the second entry carries the worktree lane's consent"
);
assert!(
set[1].cwd.is_some(),
"and the local half beside it, so the two halves are both shown"
);
assert_eq!(
set[2].tool.name, "fetch",
"the third entry is the pinned server"
);
}
#[test]
fn the_web_tool_is_an_ordinary_entry_whose_command_is_the_bridge() {
let set: Vec<Local> = read(Path::new(&root().join("docs").join("tools.example.json")))
.expect("the example is a document thrall reads");
let fetch = &set[2];
assert_eq!(fetch.command[1], "mcp", "{:?}", fetch.command);
assert_eq!(fetch.command[2], "fetch", "{:?}", fetch.command);
assert_eq!(fetch.command[3], "--", "{:?}", fetch.command);
assert!(
fetch.command[0].ends_with("thrall"),
"the bridge's command must name this binary: {:?}",
fetch.command
);
assert!(
fetch.tool.description.starts_with("Fetches a URL"),
"the description is the server's own words, carried verbatim"
);
}
#[test]
fn the_readme_says_the_web_tool_is_a_pinned_server() {
let readme = readme();
for said in [
"thrall mcp pin -- uvx mcp-server-fetch",
"writes nothing",
"never advertised",
"server's own words",
"own pin",
] {
assert!(
readme.contains(said),
"the pinned-server paragraph no longer says {said:?} — an operator \
who pastes an entry without it is trusting text nobody read"
);
}
}
#[test]
fn the_readme_carries_the_example_verbatim() {
assert!(
readme().contains(example().trim_end()),
"the README's `{TOOLS}` block is no longer the shipped example — one of \
the two moved. docs/tools.example.json is the document; the README \
block is its rendering, and they are one fact."
);
}
#[test]
fn the_readme_states_the_stdin_stdout_contract() {
let readme = readme();
for said in [
"standard input",
"standard output",
"exit code",
"argv, spawned directly",
] {
assert!(
readme.contains(said),
"the tool contract no longer says {said:?} — it is stated nowhere \
else a reader will look, and a source comment is not a document"
);
}
}