use keyhog::orchestrator_config::load_detectors_or_embedded;
use keyhog::subcommands::explain::{canonical_for_hot_id, explain_not_found};
use keyhog_core::DetectorSpec;
use std::path::Path;
fn embedded() -> Vec<DetectorSpec> {
load_detectors_or_embedded(Path::new("detectors")).expect("embedded detector corpus must load")
}
#[test]
fn hot_ids_resolve_to_real_detectors() {
let detectors = embedded();
let ids: std::collections::HashSet<String> =
detectors.iter().map(|d| d.id.to_lowercase()).collect();
for hot in [
"hot-github_pat",
"hot-openai_key",
"hot-aws_key",
"hot-aws_session_key",
"hot-sendgrid_key",
"hot-slack_bot_token",
"hot-slack_user_token",
] {
let canon = canonical_for_hot_id(hot)
.unwrap_or_else(|| panic!("{hot} must map to a canonical detector"));
assert!(
ids.contains(canon),
"{hot} maps to '{canon}', which is not in the embedded registry \
(detector renamed? update canonical_for_hot_id)"
);
}
assert!(canonical_for_hot_id("hot-square_secret").is_none());
let err = explain_not_found(&detectors, "hot-square_secret", "hot-square_secret");
let msg = format!("{err}");
assert!(
msg.contains("fast-path"),
"hot-square_secret should explain it is a fast-path pattern, got: {msg}"
);
}