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

Function test_engine_skill_hook_pattern_matcher

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

Source from the content-addressed store, hash-verified

764
765 #[tokio::test]
766 async fn test_engine_skill_hook_pattern_matcher() {
767 let engine = HookEngine::new();
768
769 // Register a hook with glob pattern
770 engine.register(
771 Hook::new("test-skill-hook", HookEventType::SkillLoad)
772 .with_matcher(HookMatcher::skill("test-*")),
773 );
774 engine.register_handler(
775 "test-skill-hook",
776 Arc::new(BlockHandler {
777 reason: "Test skill blocked".to_string(),
778 }),
779 );
780
781 // Should match pattern
782 let test_skill = make_skill_load_event("test-alpha", vec!["tool1"]);
783 let result = engine.fire(&test_skill).await;
784 assert!(result.is_block());
785
786 let test_skill2 = make_skill_load_event("test-beta", vec!["tool1"]);
787 let result = engine.fire(&test_skill2).await;
788 assert!(result.is_block());
789
790 // Should not match pattern
791 let prod_skill = make_skill_load_event("prod-skill", vec!["tool1"]);
792 let result = engine.fire(&prod_skill).await;
793 assert!(result.is_continue());
794 }
795}

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