TestRunHookRouting tests that RunHook routes to correct handlers
(t *testing.T)
| 97 | |
| 98 | // TestRunHookRouting tests that RunHook routes to correct handlers |
| 99 | func TestRunHookRouting(t *testing.T) { |
| 100 | // Test unknown hook returns error |
| 101 | err := RunHook("unknown-hook", "/tmp") |
| 102 | if err == nil { |
| 103 | t.Error("expected error for unknown hook") |
| 104 | } |
| 105 | if !strings.Contains(err.Error(), "unknown hook") { |
| 106 | t.Errorf("error should mention 'unknown hook', got: %v", err) |
| 107 | } |
| 108 | if !strings.Contains(err.Error(), "Available:") { |
| 109 | t.Errorf("error should list available hooks, got: %v", err) |
| 110 | } |
| 111 | |
| 112 | // Verify all known hooks are listed in error message |
| 113 | knownHooks := []string{"session-start", "pre-edit", "post-edit", "prompt-submit", "pre-compact", "session-stop"} |
| 114 | for _, hook := range knownHooks { |
| 115 | if !strings.Contains(err.Error(), hook) { |
| 116 | t.Errorf("error should list %q as available hook", hook) |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | func TestRunWithTimeout(t *testing.T) { |
| 122 | t.Run("returns function result before timeout", func(t *testing.T) { |