MCPcopy Index your code
hub / github.com/AI45Lab/Code / test_engine_matching_hooks

Function test_engine_matching_hooks

core/src/hooks/engine.rs:525–554  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

523
524 #[test]
525 fn test_engine_matching_hooks() {
526 let engine = HookEngine::new();
527
528 // Register multiple hooks
529 engine.register(
530 Hook::new("hook-1", HookEventType::PreToolUse).with_config(HookConfig {
531 priority: 10,
532 ..Default::default()
533 }),
534 );
535 engine.register(
536 Hook::new("hook-2", HookEventType::PreToolUse)
537 .with_matcher(HookMatcher::tool("Bash"))
538 .with_config(HookConfig {
539 priority: 5,
540 ..Default::default()
541 }),
542 );
543 engine.register(Hook::new("hook-3", HookEventType::PostToolUse));
544
545 let event = make_pre_tool_event("s1", "Bash");
546 let matching = engine.matching_hooks(&event);
547
548 // Should match hook-1 and hook-2 (both are PreToolUse)
549 assert_eq!(matching.len(), 2);
550
551 // Sorted by priority, hook-2 (priority=5) should be first
552 assert_eq!(matching[0].id, "hook-2");
553 assert_eq!(matching[1].id, "hook-1");
554 }
555
556 #[tokio::test]
557 async fn test_engine_fire_no_hooks() {

Callers

nothing calls this directly

Calls 5

with_matcherMethod · 0.80
matching_hooksMethod · 0.80
make_pre_tool_eventFunction · 0.70
registerMethod · 0.45
with_configMethod · 0.45

Tested by

no test coverage detected