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

Function test_engine_skill_hook_with_matcher

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

Source from the content-addressed store, hash-verified

737
738 #[tokio::test]
739 async fn test_engine_skill_hook_with_matcher() {
740 let engine = HookEngine::new();
741
742 // Register a hook that only matches specific skill
743 engine.register(
744 Hook::new("specific-skill-hook", HookEventType::SkillLoad)
745 .with_matcher(HookMatcher::skill("my-skill")),
746 );
747 engine.register_handler(
748 "specific-skill-hook",
749 Arc::new(BlockHandler {
750 reason: "Skill blocked".to_string(),
751 }),
752 );
753
754 // Should match and block
755 let matching_event = make_skill_load_event("my-skill", vec!["tool1"]);
756 let result = engine.fire(&matching_event).await;
757 assert!(result.is_block());
758
759 // Should not match (no hooks match, so continue)
760 let non_matching_event = make_skill_load_event("other-skill", vec!["tool1"]);
761 let result = engine.fire(&non_matching_event).await;
762 assert!(result.is_continue());
763 }
764
765 #[tokio::test]
766 async fn test_engine_skill_hook_pattern_matcher() {

Callers

nothing calls this directly

Calls 5

with_matcherMethod · 0.80
register_handlerMethod · 0.80
make_skill_load_eventFunction · 0.70
registerMethod · 0.45
fireMethod · 0.45

Tested by

no test coverage detected