MCPcopy Index your code
hub / github.com/cli/cli / TestProjectsV2ItemsForPullRequest

Function TestProjectsV2ItemsForPullRequest

api/queries_projects_v2_test.go:166–287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

164}
165
166func TestProjectsV2ItemsForPullRequest(t *testing.T) {
167 var tests = []struct {
168 name string
169 httpStubs func(*httpmock.Registry)
170 expectItems ProjectItems
171 expectError bool
172 }{
173 {
174 name: "retrieves project items for pull request",
175 httpStubs: func(reg *httpmock.Registry) {
176 reg.Register(
177 httpmock.GraphQL(`query PullRequestProjectItems\b`),
178 httpmock.GraphQLQuery(`{"data":{"repository":{"pullRequest":{"projectItems":{"nodes": [{"id":"projectItem3"},{"id":"projectItem4"}]}}}}}`,
179 func(query string, inputs map[string]interface{}) {}),
180 )
181 },
182 expectItems: ProjectItems{
183 Nodes: []*ProjectV2Item{
184 {ID: "projectItem3"},
185 {ID: "projectItem4"},
186 },
187 },
188 },
189 {
190 name: "fails to retrieve project items for pull request",
191 httpStubs: func(reg *httpmock.Registry) {
192 reg.Register(
193 httpmock.GraphQL(`query PullRequestProjectItems\b`),
194 httpmock.GraphQLQuery(`{"data":{}, "errors": [{"message": "some gql error"}]}`,
195 func(query string, inputs map[string]interface{}) {}),
196 )
197 },
198 expectError: true,
199 },
200 {
201 name: "skips null project items for pull request",
202 httpStubs: func(reg *httpmock.Registry) {
203 reg.Register(
204 httpmock.GraphQL(`query PullRequestProjectItems\b`),
205 httpmock.GraphQLQuery(`{"data":{"repository":{"pullRequest":{"projectItems":{"totalCount":1,"nodes":[null]}}}}}`,
206 func(query string, inputs map[string]interface{}) {}),
207 )
208 },
209 expectItems: ProjectItems{},
210 },
211 {
212 name: "retrieves project items that have status columns",
213 httpStubs: func(reg *httpmock.Registry) {
214 reg.Register(
215 httpmock.GraphQL(`query PullRequestProjectItems\b`),
216 httpmock.GraphQLQuery(`{
217 "data": {
218 "repository": {
219 "pullRequest": {
220 "projectItems": {
221 "nodes": [
222 {
223 "id": "PVTI_lADOB-vozM4AVk16zgK6U50",

Callers

nothing calls this directly

Calls 10

RegisterMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
GraphQLQueryFunction · 0.92
FromFullNameFunction · 0.92
newTestClientFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected