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

Function TestClassifyList

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

Source from the content-addressed store, hash-verified

111}
112
113func TestClassifyList(t *testing.T) {
114 doc := loadDoc(t, `
115openapi: 3.0.0
116info: { title: Test, version: 1.0.0 }
117paths:
118 /audit-logs:
119 get:
120 operationId: listAuditLogs
121 parameters:
122 - { name: actorId, in: query, schema: { type: string } }
123 responses:
124 '200':
125 description: ok
126 content:
127 application/json:
128 schema:
129 type: object
130 properties:
131 data:
132 type: array
133 items: { type: object }
134`)
135
136 spec := &Spec{Key: "test"}
137 ops, _ := classifyAll(spec, doc, SpecConfig{})
138 if ops[0].Mode != OpModeList {
139 t.Errorf("mode = %v, want OpModeList", ops[0].Mode)
140 }
141 if !ops[0].IsArrayResponse {
142 t.Error("IsArrayResponse should be true for {data: [...]} shape")
143 }
144 if len(ops[0].ResultPath) != 1 || ops[0].ResultPath[0] != "data" {
145 t.Errorf("result_path = %v, want [data]", ops[0].ResultPath)
146 }
147 if len(ops[0].QueryParams) != 1 || ops[0].QueryParams[0].Name != "actorId" {
148 t.Errorf("query params = %+v", ops[0].QueryParams)
149 }
150}
151
152func TestClassifySkipReasons(t *testing.T) {
153 cases := []struct {

Callers

nothing calls this directly

Calls 3

loadDocFunction · 0.85
classifyAllFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected