MCPcopy Create free account
hub / github.com/github/gh-aw / TestGenerateExampleJSONForPath

Function TestGenerateExampleJSONForPath

pkg/parser/schema_suggestions_test.go:253–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

251}
252
253func TestGenerateExampleJSONForPath(t *testing.T) {
254 schemaJSON := `{
255 "type": "object",
256 "properties": {
257 "timeout_minutes": {"type": "integer"},
258 "name": {"type": "string"},
259 "active": {"type": "boolean"},
260 "tags": {
261 "type": "array",
262 "items": {"type": "string"}
263 },
264 "config": {
265 "type": "object",
266 "properties": {
267 "enabled": {"type": "boolean"},
268 "count": {"type": "integer"}
269 }
270 }
271 }
272 }`
273
274 var schemaDoc any
275 require.NoError(t, json.Unmarshal([]byte(schemaJSON), &schemaDoc), "Failed to unmarshal schema")
276
277 tests := []struct {
278 name string
279 jsonPath string
280 wantContains []string
281 }{
282 {
283 name: "integer field",
284 jsonPath: "/timeout_minutes",
285 wantContains: []string{"42"},
286 },
287 {
288 name: "string field",
289 jsonPath: "/name",
290 wantContains: []string{`"string"`},
291 },
292 {
293 name: "boolean field",
294 jsonPath: "/active",
295 wantContains: []string{"true"},
296 },
297 {
298 name: "array field",
299 jsonPath: "/tags",
300 wantContains: []string{"[", `"string"`, "]"},
301 },
302 {
303 name: "object field",
304 jsonPath: "/config",
305 wantContains: []string{"{", "}", "enabled", "count"},
306 },
307 }
308
309 for _, tt := range tests {
310 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected