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

Function TestInputToJSON

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

Source from the content-addressed store, hash-verified

142}
143
144func TestInputToJSON(t *testing.T) {
145 t.Parallel()
146
147 input := &Input{
148 SessionID: "sess-123",
149 Cwd: "/tmp",
150 HookEventName: EventPreToolUse,
151 ToolName: "shell",
152 ToolUseID: "tool-456",
153 ToolInput: map[string]any{
154 "cmd": "ls -la",
155 "cwd": ".",
156 },
157 }
158
159 data, err := input.ToJSON()
160 require.NoError(t, err)
161
162 var parsed map[string]any
163 err = json.Unmarshal(data, &parsed)
164 require.NoError(t, err)
165
166 assert.Equal(t, "sess-123", parsed["session_id"])
167 assert.Equal(t, "/tmp", parsed["cwd"])
168 assert.Equal(t, "pre_tool_use", parsed["hook_event_name"])
169 assert.Equal(t, "shell", parsed["tool_name"])
170 assert.Equal(t, "tool-456", parsed["tool_use_id"])
171}
172
173func TestOutputShouldContinue(t *testing.T) {
174 t.Parallel()

Callers

nothing calls this directly

Calls 1

ToJSONMethod · 0.95

Tested by

no test coverage detected