MCPcopy Create free account
hub / github.com/cli/cli / TestPRRepositorySelectionMatchesStruct

Function TestPRRepositorySelectionMatchesStruct

api/queries_pr_test.go:574–587  ·  view source on GitHub ↗

TestPRRepositorySelectionMatchesStruct guards the seam between the two: a field added to the selection but not the struct is silently dropped, and one added to the struct but not the selection is silently zero.

(t *testing.T)

Source from the content-addressed store, hash-verified

572// a field added to the selection but not the struct is silently dropped, and
573// one added to the struct but not the selection is silently zero.
574func TestPRRepositorySelectionMatchesStruct(t *testing.T) {
575 selection := PullRequestGraphQL([]string{"repository"})
576 inner := strings.TrimSuffix(strings.TrimPrefix(selection, "repository{"), "}")
577 selected := strings.Split(inner, ",")
578
579 var declared []string
580 repositoryType := reflect.TypeFor[PRRepository]()
581 for field := range repositoryType.Fields() {
582 name, _, _ := strings.Cut(field.Tag.Get("json"), ",")
583 declared = append(declared, name)
584 }
585
586 assert.ElementsMatch(t, declared, selected)
587}
588
589func TestPullRequestRepositoryDatabaseID(t *testing.T) {
590 tests := []struct {

Callers

nothing calls this directly

Calls 3

PullRequestGraphQLFunction · 0.85
FieldsMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected