(t *testing.T)
| 430 | } |
| 431 | |
| 432 | func TestExecutePreToolUseWithJSONOutput(t *testing.T) { |
| 433 | t.Parallel() |
| 434 | |
| 435 | jsonOutput := `{"decision":"block","reason":"Tool not allowed"}` |
| 436 | config := &Config{ |
| 437 | PreToolUse: []MatcherConfig{ |
| 438 | { |
| 439 | Matcher: "*", |
| 440 | Hooks: []Hook{ |
| 441 | {Type: HookTypeCommand, Command: "echo '" + jsonOutput + "'", Timeout: 5}, |
| 442 | }, |
| 443 | }, |
| 444 | }, |
| 445 | } |
| 446 | |
| 447 | exec := NewExecutor(config, t.TempDir(), nil) |
| 448 | input := &Input{ |
| 449 | SessionID: "test-session", |
| 450 | ToolName: "shell", |
| 451 | ToolUseID: "test-id", |
| 452 | } |
| 453 | |
| 454 | result, err := exec.Dispatch(t.Context(), EventPreToolUse, input) |
| 455 | require.NoError(t, err) |
| 456 | assert.False(t, result.Allowed) |
| 457 | assert.Contains(t, result.Message, "Tool not allowed") |
| 458 | } |
| 459 | |
| 460 | func TestExecutePostToolUse(t *testing.T) { |
| 461 | t.Parallel() |
nothing calls this directly
no test coverage detected