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

Function TestAppendKnownFieldValidValuesHint

pkg/parser/schema_errors_test.go:421–489  ·  view source on GitHub ↗

TestAppendKnownFieldValidValuesHint tests that the hint function appends valid values, "Did you mean?" suggestions, and documentation links for well-known schema paths.

(t *testing.T)

Source from the content-addressed store, hash-verified

419// TestAppendKnownFieldValidValuesHint tests that the hint function appends valid values,
420// "Did you mean?" suggestions, and documentation links for well-known schema paths.
421func TestAppendKnownFieldValidValuesHint(t *testing.T) {
422 tests := []struct {
423 name string
424 message string
425 jsonPath string
426 contains []string // substrings that must appear
427 excludes []string // substrings that must NOT appear
428 }{
429 {
430 name: "no hint for non-unknown-property message",
431 message: "value must be one of 'read', 'write', 'none'",
432 jsonPath: "/permissions",
433 contains: []string{"value must be one of"},
434 excludes: []string{"Valid permission scopes", "See:"},
435 },
436 {
437 name: "hint appended for permissions path",
438 message: "Unknown property: issuess",
439 jsonPath: "/permissions",
440 contains: []string{"Valid permission scopes", "See: https://docs.github.com"},
441 },
442 {
443 name: "did you mean suggestion for close typo",
444 message: "Unknown property: issuess",
445 jsonPath: "/permissions",
446 contains: []string{"Did you mean 'issues'?"},
447 },
448 {
449 name: "did you mean suggestion for another typo",
450 message: "Unknown property: contnets",
451 jsonPath: "/permissions",
452 contains: []string{"Did you mean 'contents'?"},
453 },
454 {
455 name: "no did you mean for unrelated word",
456 message: "Unknown property: completely-unknown-xyz",
457 jsonPath: "/permissions",
458 excludes: []string{"Did you mean"},
459 contains: []string{"Valid permission scopes"},
460 },
461 {
462 name: "no hint for unknown path",
463 message: "Unknown property: foo",
464 jsonPath: "/some-unknown-path",
465 contains: []string{"Unknown property: foo"},
466 excludes: []string{"Valid permission scopes", "See:"},
467 },
468 {
469 name: "hint works for nested permissions path",
470 message: "Unknown property: issuess",
471 jsonPath: "/permissions/issuess",
472 contains: []string{"Valid permission scopes", "See: https://docs.github.com"},
473 },
474 }
475
476 for _, tt := range tests {
477 t.Run(tt.name, func(t *testing.T) {
478 result, _ := appendKnownFieldValidValuesHint(tt.message, tt.jsonPath)

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected