test(cli): RED — a missing [nodes] dir leaks the cargo metadata error (#245)
RED pin: a_missing_nodes_pointer_dir_refuses_without_the_cargo_metadata_leak (project.rs unit tests) — the refusal must name the absent directory and keep the [nodes] context, with no cargo-metadata wrap. refs #245
This commit is contained in:
@@ -622,6 +622,38 @@ mod tests {
|
||||
std::fs::remove_dir_all(&tmp).ok();
|
||||
}
|
||||
|
||||
/// #245: a `[nodes]` pointer at a directory that does not exist refuses
|
||||
/// with a clean message — it names the missing directory and keeps the
|
||||
/// `[nodes]` pointer context, but does NOT leak the raw `cargo metadata`
|
||||
/// toolchain error. That wrap is reserved for a directory that exists but
|
||||
/// is not a valid crate; a plainly-absent directory should say exactly
|
||||
/// that (`load` still refuses → CLI exit 1).
|
||||
#[test]
|
||||
fn a_missing_nodes_pointer_dir_refuses_without_the_cargo_metadata_leak() {
|
||||
let tmp = std::env::temp_dir().join(format!("aura-missingptr-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&tmp).unwrap();
|
||||
// `missing-node-crate` is never created — the pointer target is absent.
|
||||
std::fs::write(
|
||||
tmp.join("Aura.toml"),
|
||||
"[nodes]\ncrates = [\"missing-node-crate\"]\n",
|
||||
)
|
||||
.unwrap();
|
||||
let e = load(&tmp, false).unwrap_err();
|
||||
let msg = e.to_string();
|
||||
// names the offending pointer path ...
|
||||
assert!(msg.contains("missing-node-crate"), "names the pointer path: {msg}");
|
||||
// ... says plainly that the directory is not there ...
|
||||
assert!(msg.contains("does not exist"), "states the directory is absent: {msg}");
|
||||
// ... keeps the [nodes] pointer context ...
|
||||
assert!(msg.contains("[nodes]"), "keeps the pointer context: {msg}");
|
||||
// ... and does not leak the raw toolchain error for a simple absence.
|
||||
assert!(
|
||||
!msg.contains("cargo metadata"),
|
||||
"no cargo-metadata leak for an absent directory: {msg}"
|
||||
);
|
||||
std::fs::remove_dir_all(&tmp).ok();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aura_toml_parses_empty_partial_and_unknown_keys() {
|
||||
let t: AuraToml = toml::from_str("").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user