use std::process::ExitCode;
use crate::hook::{HookEvent, read_stdin, run_hook_event};
pub fn handle_hook_event(
config: &crate::config::Config,
_json: bool,
event: HookEvent,
) -> Result<ExitCode, crate::errors::Error> {
let input = read_stdin();
run_hook_event(config, event, &input)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::hook::run_hook_event;
#[test]
fn handle_hook_event_delegates_to_pipeline() {
let config = crate::config::Config::default();
let result =
handle_hook_event(&config, false, HookEvent::UserPromptSubmit).expect("adapter ok");
assert_eq!(result, ExitCode::SUCCESS);
}
#[test]
fn pipeline_returns_success_on_garbage_input() {
let config = crate::config::Config::default();
let exit = run_hook_event(&config, HookEvent::UserPromptSubmit, "not json")
.expect("garbage stdin must not error");
assert_eq!(exit, ExitCode::SUCCESS);
}
}