use faultbox::{Adhoc, Capture, Config, EventKind};
#[test]
fn each_emit_is_its_own_report_faultbox_cannot_infer_a_shared_root_cause() {
let tmp = tempfile::tempdir().unwrap();
let reports = tmp.path().join("reports");
assert!(
faultbox::init(Config::new("theapp", "0.1.0", &reports).install_panic_hook(false)),
"this binary's only init must win, or the reports land elsewhere"
);
for (kind, key) in [
("storage.checksum", "class=checksum"),
("database.read", "class=io"),
] {
let ctx = Adhoc {
kind,
key: key.to_owned(),
value: serde_json::Value::Null,
};
let _ = Capture::new(EventKind::Corruption, "read failed")
.domain(&ctx)
.emit();
}
let groups = faultbox::reader::list(&reports).unwrap();
assert_eq!(
groups.len(),
2,
"two emits for one root cause produce two groups; dedup is the \
adopter's job, by only reporting at the detection site"
);
}