(t *testing.T)
| 377 | } |
| 378 | |
| 379 | func TestExecutePreToolUseBlockingExitCode(t *testing.T) { |
| 380 | t.Parallel() |
| 381 | |
| 382 | config := &Config{ |
| 383 | PreToolUse: []MatcherConfig{ |
| 384 | { |
| 385 | Matcher: "*", |
| 386 | Hooks: []Hook{ |
| 387 | {Type: HookTypeCommand, Command: "exit 2", Timeout: 5}, |
| 388 | }, |
| 389 | }, |
| 390 | }, |
| 391 | } |
| 392 | |
| 393 | exec := NewExecutor(config, t.TempDir(), nil) |
| 394 | input := &Input{ |
| 395 | SessionID: "test-session", |
| 396 | ToolName: "shell", |
| 397 | ToolUseID: "test-id", |
| 398 | } |
| 399 | |
| 400 | result, err := exec.Dispatch(t.Context(), EventPreToolUse, input) |
| 401 | require.NoError(t, err) |
| 402 | assert.False(t, result.Allowed) |
| 403 | assert.Equal(t, 2, result.ExitCode) |
| 404 | } |
| 405 | |
| 406 | func TestExecutePreToolUseNoMatchingHooks(t *testing.T) { |
| 407 | t.Parallel() |
nothing calls this directly
no test coverage detected