feat: add rh Connect facade and tool coverage
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
package rh_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"s1d3sw1ped/robinhood-agentic-mcp"
|
||||
"s1d3sw1ped/robinhood-agentic-mcp/auth"
|
||||
"s1d3sw1ped/robinhood-agentic-mcp/equity"
|
||||
"s1d3sw1ped/robinhood-agentic-mcp/internal/rhntest"
|
||||
)
|
||||
|
||||
func TestRegisteredTools_matchesFixture(t *testing.T) {
|
||||
t.Parallel()
|
||||
raw, err := os.ReadFile("testdata/tools.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var want []string
|
||||
if err := json.Unmarshal(raw, &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := rh.RegisteredTools()
|
||||
sort.Strings(want)
|
||||
sort.Strings(got)
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
t.Fatal(diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConnect_rpcFallback(t *testing.T) {
|
||||
s := rhntest.New(t)
|
||||
s.Token = "tok"
|
||||
s.Set("get_equity_quotes", json.RawMessage(`{"quotes":[]}`))
|
||||
path := filepath.Join(t.TempDir(), "tokens.json")
|
||||
if err := auth.WriteTokens(path, "tok", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
api, err := rh.Connect(t.Context(), rh.Config{URL: s.URL, TokenFile: path, Name: "tradey"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = api.Equity.Quotes(t.Context(), equity.QuotesRequest{Symbols: []string{"MU"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user