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

Function TestClassifyRowJoinUpgrade

core/openapi/classifier_test.go:73–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestClassifyRowJoinUpgrade(t *testing.T) {
74 doc := loadDoc(t, `
75openapi: 3.0.0
76info: { title: Test, version: 1.0.0 }
77paths:
78 /users/{userId}:
79 get:
80 operationId: getUserById
81 parameters:
82 - { name: userId, in: path, required: true, schema: { type: string } }
83 responses:
84 '200':
85 description: ok
86 content: { application/json: { schema: { type: object } } }
87`)
88
89 cfg := SpecConfig{
90 Joins: map[string]JoinConfig{
91 "getUserById": {
92 ParentTable: "users",
93 ParentColumn: "email",
94 Param: "userId",
95 ExposeAs: "is_profile",
96 },
97 },
98 }
99
100 spec := &Spec{Key: "test"}
101 ops, _ := classifyAll(spec, doc, cfg)
102 if ops[0].Mode != OpModeRowJoin {
103 t.Errorf("mode = %v, want OpModeRowJoin", ops[0].Mode)
104 }
105 if ops[0].Join == nil || ops[0].Join.ParentTable != "users" {
106 t.Errorf("join not wired correctly: %+v", ops[0].Join)
107 }
108 if ops[0].ExposeAs != "is_profile" {
109 t.Errorf("expose_as override not applied: %q", ops[0].ExposeAs)
110 }
111}
112
113func TestClassifyList(t *testing.T) {
114 doc := loadDoc(t, `

Callers

nothing calls this directly

Calls 2

loadDocFunction · 0.85
classifyAllFunction · 0.85

Tested by

no test coverage detected