package mcpresource import ( "amadan.net/rastrillo/rastrillo/budget" "encoding/json" "os" "testing" ) func TestRoutingResourceOnly(t *testing.T) { for _, q := range []struct{ method, params, want string }{ {"resources/list", `{}`, `{"resources":[{"mimeType":"text/plain","name":"routing-check","uri":"equipo://routing-check"}]}`}, {"resources/templates/list", `{}`, `{"resourceTemplates":[]}`}, {"resources/read", `{"uri":"equipo://routing-check"}`, `{"contents":[{"mimeType":"text/plain","text":"equipo-routing-ready","uri":"equipo://routing-check"}]}`}, // Captured from Codex 0.165.0 during round 2, live-1. {"resources/read", `{"_meta":{"progressToken":6},"uri":"equipo://routing-check"}`, `{"contents":[{"mimeType":"text/plain","text":"equipo-routing-ready","uri":"equipo://routing-check"}]}`}, {"resources/read", `{"uri":"file:///workspace/private"}`, ""}, {"resources/read", `{"uri":"equipo://routing-check/other"}`, ""}, {"resources/read", `{"uri":"equipo://routing-check","path":"/home/runner"}`, ""}, {"resources/write", `{"uri":"equipo://routing-check","text":"changed"}`, ""}, } { t.Run(q.method+q.params, func(t *testing.T) { result, err := Result(q.method, json.RawMessage(q.params)) if q.want == "" { if err == nil { t.Fatal("invalid request accepted", result) } return } raw, marshalErr := json.Marshal(result) if err != nil || marshalErr != nil || string(raw) != q.want { t.Fatalf("result=%s err=%v marshal=%v", raw, err, marshalErr) } }) } } func TestMain(m *testing.M) { os.Exit(budget.Main(m)) }