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

Function test_hook_serialization

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

Source from the content-addressed store, hash-verified

659
660 #[test]
661 fn test_hook_serialization() {
662 let hook = Hook::new("test-hook", HookEventType::PreToolUse)
663 .with_matcher(HookMatcher::tool("Bash"))
664 .with_config(HookConfig {
665 priority: 50,
666 timeout_ms: 5000,
667 async_execution: true,
668 max_retries: 3,
669 });
670
671 let json = serde_json::to_string(&hook).unwrap();
672 assert!(json.contains("test-hook"));
673 assert!(json.contains("pre_tool_use"));
674 assert!(json.contains("Bash"));
675
676 let parsed: Hook = serde_json::from_str(&json).unwrap();
677 assert_eq!(parsed.id, "test-hook");
678 assert_eq!(parsed.event_type, HookEventType::PreToolUse);
679 assert_eq!(parsed.config.priority, 50);
680 }
681
682 #[test]
683 fn test_all_hooks() {

Callers

nothing calls this directly

Calls 2

with_matcherMethod · 0.80
with_configMethod · 0.45

Tested by

no test coverage detected