MCPcopy Index your code
hub / github.com/docker/docker-agent / TestExecutePreToolUseBlockingExitCode

Function TestExecutePreToolUseBlockingExitCode

pkg/hooks/hooks_test.go:379–404  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

377}
378
379func 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
406func TestExecutePreToolUseNoMatchingHooks(t *testing.T) {
407 t.Parallel()

Callers

nothing calls this directly

Calls 3

DispatchMethod · 0.95
NewExecutorFunction · 0.85
ContextMethod · 0.80

Tested by

no test coverage detected