(t *testing.T)
| 164 | } |
| 165 | |
| 166 | func 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", |
nothing calls this directly
no test coverage detected