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(), 2, "the ball asked for two entries");
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"
);
}
#[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"
);
}
}