()
| 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() { |
nothing calls this directly
no test coverage detected