package rhntest_test import ( "bytes" "encoding/json" "io" "net/http" "testing" "s1d3sw1ped/robinhood-agentic-mcp/internal/rhntest" ) func TestServer_toolsCall(t *testing.T) { t.Parallel() s := rhntest.New(t) s.Token = "tok" s.Set("get_accounts", json.RawMessage(`{"accounts":[]}`)) body, _ := json.Marshal(map[string]any{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": map[string]any{"name": "get_accounts", "arguments": map[string]any{}}, }) req, _ := http.NewRequest(http.MethodPost, s.URL, bytes.NewReader(body)) req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "Bearer tok") resp, err := http.DefaultClient.Do(req) if err != nil { t.Fatal(err) } defer resp.Body.Close() raw, _ := io.ReadAll(resp.Body) if resp.StatusCode != 200 { t.Fatalf("%d %s", resp.StatusCode, raw) } var out struct { Result json.RawMessage `json:"result"` } if err := json.Unmarshal(raw, &out); err != nil { t.Fatal(err) } if string(out.Result) != `{"accounts":[]}` { t.Fatalf("%s", out.Result) } if s.LastName() != "get_accounts" { t.Fatalf("%q", s.LastName()) } }