(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func TestAPITool_POST(t *testing.T) { |
| 89 | t.Parallel() |
| 90 | ts := getTestServer(t) |
| 91 | |
| 92 | tool := newAPIToolForTest(latest.APIToolConfig{ |
| 93 | Method: http.MethodPost, |
| 94 | Endpoint: ts.serverURL, |
| 95 | }, testExpander()) |
| 96 | |
| 97 | result, err := tool.callTool(t.Context(), tools.ToolCall{ |
| 98 | Function: tools.FunctionCall{ |
| 99 | Arguments: `{"name":"John Doe","age":30}`, |
| 100 | }, |
| 101 | }) |
| 102 | |
| 103 | require.NoError(t, err) |
| 104 | assert.JSONEq(t, `{"status":"ok"}`, result.Output) |
| 105 | assert.Equal(t, http.MethodPost, ts.receivedMethod) |
| 106 | assert.Equal(t, "application/json", ts.receivedHeaders.Get("Content-Type")) |
| 107 | |
| 108 | var receivedData map[string]any |
| 109 | err = json.Unmarshal(ts.receivedBody, &receivedData) |
| 110 | require.NoError(t, err) |
| 111 | assert.Equal(t, "John Doe", receivedData["name"]) |
| 112 | assert.InEpsilon(t, 30.0, receivedData["age"], 0.01) |
| 113 | } |
| 114 | |
| 115 | func TestAPITool_Headers(t *testing.T) { |
| 116 | t.Parallel() |
nothing calls this directly
no test coverage detected