MCPcopy
hub / github.com/dosco/graphjin / TestGraphQLControlPlaneCatalogQuery

Function TestGraphQLControlPlaneCatalogQuery

serv/control_plane_graphql_test.go:21–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestGraphQLControlPlaneCatalogQuery(t *testing.T) {
22 svc := newControlPlaneGraphQLTestService(t, MCPConfig{}, createSQLiteDBFile(t, "app.sqlite3", true))
23
24 res, err := svc.gj.GraphQL(sourceModeUserTestContext(), `query {
25 gj_catalog(search: "users", where: { kind: { eq: "table" } }, order_by: { search_rank: desc }, limit: 5) {
26 id
27 kind
28 name
29 table_name
30 search_rank
31 }
32 }`, nil, &core.RequestConfig{})
33 if err != nil {
34 t.Fatalf("control-plane catalog query error: %v", err)
35 }
36 if len(res.Errors) != 0 {
37 t.Fatalf("control-plane catalog query returned errors: %+v", res.Errors)
38 }
39
40 var out struct {
41 Items []struct {
42 ID string `json:"id"`
43 Kind string `json:"kind"`
44 Name string `json:"name"`
45 TableName string `json:"table_name"`
46 Score float64 `json:"search_rank"`
47 } `json:"gj_catalog"`
48 }
49 if err := json.Unmarshal(res.Data, &out); err != nil {
50 t.Fatalf("decode catalog query: %v\n%s", err, string(res.Data))
51 }
52 if len(out.Items) == 0 {
53 t.Fatalf("expected catalog items, got %s", string(res.Data))
54 }
55 if out.Items[0].Kind != "table" || out.Items[0].TableName != "users" || out.Items[0].Name != "users" {
56 t.Fatalf("expected users table item first, got %+v", out.Items[0])
57 }
58 if out.Items[0].Score <= 0 {
59 t.Fatalf("expected positive search score, got %+v", out.Items[0])
60 }
61}
62
63func TestGraphQLControlPlaneCatalogIncludesFragments(t *testing.T) {
64 svc := newControlPlaneGraphQLTestService(t, MCPConfig{}, createSQLiteDBFile(t, "app.sqlite3", true))

Callers

nothing calls this directly

Calls 4

createSQLiteDBFileFunction · 0.85
GraphQLMethod · 0.45

Tested by

no test coverage detected