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

Function test_engine_fire_priority_order

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

Source from the content-addressed store, hash-verified

626
627 #[tokio::test]
628 async fn test_engine_fire_priority_order() {
629 let engine = HookEngine::new();
630
631 // Register two hooks, lower priority one blocks
632 engine.register(
633 Hook::new("block-hook", HookEventType::PreToolUse).with_config(HookConfig {
634 priority: 5, // Higher priority (executes first)
635 ..Default::default()
636 }),
637 );
638 engine.register(
639 Hook::new("continue-hook", HookEventType::PreToolUse).with_config(HookConfig {
640 priority: 10,
641 ..Default::default()
642 }),
643 );
644
645 engine.register_handler(
646 "block-hook",
647 Arc::new(BlockHandler {
648 reason: "Blocked first".to_string(),
649 }),
650 );
651 engine.register_handler("continue-hook", Arc::new(ContinueHandler));
652
653 let event = make_pre_tool_event("s1", "Bash");
654 let result = engine.fire(&event).await;
655
656 // block-hook executes first, should block
657 assert!(result.is_block());
658 }
659
660 #[test]
661 fn test_hook_serialization() {

Callers

nothing calls this directly

Calls 5

register_handlerMethod · 0.80
make_pre_tool_eventFunction · 0.70
registerMethod · 0.45
with_configMethod · 0.45
fireMethod · 0.45

Tested by

no test coverage detected