use std::process::Command;
#[test]
fn missing_file_exits_with_the_io_error_code() {
let output = Command::new(env!("CARGO_BIN_EXE_mif-cli"))
.args(["validate", "/nonexistent/mif-cli-fixture.json"])
.output()
.unwrap();
assert_eq!(output.status.code(), Some(1));
}
#[test]
fn invalid_json_exits_with_the_mapped_error_code() {
let file = tempfile::NamedTempFile::new().unwrap();
std::fs::write(file.path(), "not valid json").unwrap();
let output = Command::new(env!("CARGO_BIN_EXE_mif-cli"))
.args(["validate", file.path().to_str().unwrap()])
.output()
.unwrap();
assert_eq!(output.status.code(), Some(2));
}
#[test]
fn a_conformant_document_exits_zero() {
let file = tempfile::NamedTempFile::new().unwrap();
std::fs::write(
file.path(),
r#"{
"@context": "https://mif-spec.dev/schema/context.jsonld",
"@type": "Concept",
"@id": "urn:mif:memory:exit-code-test",
"conceptType": "semantic",
"content": "Content.",
"created": "2026-07-02T00:00:00Z"
}"#,
)
.unwrap();
let output = Command::new(env!("CARGO_BIN_EXE_mif-cli"))
.args(["validate", file.path().to_str().unwrap()])
.output()
.unwrap();
assert_eq!(output.status.code(), Some(0));
}