use std::path::Path;
use std::process::Command;
fn shipped_doc() -> String {
let p = Path::new(env!("CARGO_MANIFEST_DIR")).join("LIMITATIONS.md");
assert!(
p.exists(),
"LIMITATIONS.md must live inside crates/btctax-cli/ or it is not in the .crate tarball \
and `cargo publish` fails to compile the packaged crate (P5-I4): {}",
p.display()
);
std::fs::read_to_string(p).expect("read LIMITATIONS.md")
}
#[test]
fn limitations_prints_the_shipped_doc_verbatim() {
let out = Command::new(env!("CARGO_BIN_EXE_btctax"))
.arg("limitations")
.output()
.expect("run btctax limitations");
assert!(out.status.success(), "exit: {:?}", out.status);
let stdout = String::from_utf8(out.stdout).expect("utf-8");
assert_eq!(
stdout,
shipped_doc(),
"`btctax limitations` must print the shipped doc byte-for-byte"
);
assert!(out.stderr.is_empty(), "nothing belongs on stderr");
}
#[test]
fn limitations_doc_has_its_three_lists() {
let doc = shipped_doc();
for heading in ["REFUS", "OMISSION", "UNREPRESENTABLE"] {
assert!(
doc.contains(heading),
"LIMITATIONS.md must still carry its {heading} list"
);
}
}
#[test]
fn limitations_carries_the_no_authorisation_notice() {
let doc = shipped_doc()
.split_whitespace()
.collect::<Vec<_>>()
.join(" ");
for clause in [
"No right is granted, and no authorisation is given",
"to prepare or file a tax return",
"no representation and give no warranty",
"a refusal is a best effort, not a guarantee",
"entirely on your own responsibility",
"accept **no liability**",
"The signature on it is yours alone.",
"is a substitute for a qualified professional",
] {
assert!(
doc.contains(clause),
"the NOTICE clause {clause:?} has been weakened or removed from LIMITATIONS.md"
);
}
assert!(
doc.contains("**MIT OR Unlicense**) — unchanged and unrestricted"),
"the licence grant must stay unrestricted — the NOTICE disclaims, it does not forbid"
);
}