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

Function TestIssueGraphQL

api/query_builder_test.go:65–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestIssueGraphQL(t *testing.T) {
66 tests := []struct {
67 name string
68 fields []string
69 want string
70 }{
71 {
72 name: "empty",
73 fields: []string(nil),
74 want: "",
75 },
76 {
77 name: "simple fields",
78 fields: []string{"number", "title"},
79 want: "number,title",
80 },
81 {
82 name: "fields with nested structures",
83 fields: []string{"author", "assignees"},
84 want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name,databaseId},totalCount}",
85 },
86 {
87 name: "compressed query",
88 fields: []string{"files"},
89 want: "files(first: 100) {nodes {additions,deletions,path,changeType}}",
90 },
91 {
92 name: "projectItems",
93 fields: []string{"projectItems"},
94 want: `projectItems(first:100){nodes{id, project{id,title}, status:fieldValueByName(name: "Status") { ... on ProjectV2ItemFieldSingleSelectValue{optionId,name}}},totalCount}`,
95 },
96 {
97 name: "repository",
98 fields: []string{"repository"},
99 want: "repository{id,name,nameWithOwner,databaseId,viewerPermission}",
100 },
101 }
102 for _, tt := range tests {
103 t.Run(tt.name, func(t *testing.T) {
104 if got := IssueGraphQL(tt.fields); got != tt.want {
105 t.Errorf("IssueGraphQL() = %v, want %v", got, tt.want)
106 }
107 })
108 }
109}

Callers

nothing calls this directly

Calls 3

IssueGraphQLFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected