| 210 | } |
| 211 | |
| 212 | func TestRunList_User(t *testing.T) { |
| 213 | defer gock.Off() |
| 214 | // gock.Observe(gock.DumpRequest) |
| 215 | |
| 216 | // get user ID |
| 217 | gock.New("https://api.github.com"). |
| 218 | Post("/graphql"). |
| 219 | MatchType("json"). |
| 220 | JSON(map[string]interface{}{ |
| 221 | "query": "query UserOrgOwner.*", |
| 222 | "variables": map[string]interface{}{ |
| 223 | "login": "monalisa", |
| 224 | }, |
| 225 | }). |
| 226 | Reply(200). |
| 227 | JSON(map[string]interface{}{ |
| 228 | "data": map[string]interface{}{ |
| 229 | "user": map[string]interface{}{ |
| 230 | "id": "an ID", |
| 231 | }, |
| 232 | }, |
| 233 | "errors": []interface{}{ |
| 234 | map[string]interface{}{ |
| 235 | "type": "NOT_FOUND", |
| 236 | "path": []string{"organization"}, |
| 237 | }, |
| 238 | }, |
| 239 | }) |
| 240 | |
| 241 | // list project items |
| 242 | gock.New("https://api.github.com"). |
| 243 | Post("/graphql"). |
| 244 | JSON(map[string]interface{}{ |
| 245 | "query": "query UserProjectWithItems.*", |
| 246 | "variables": map[string]interface{}{ |
| 247 | "firstItems": queries.LimitDefault, |
| 248 | "afterItems": nil, |
| 249 | "firstFields": queries.LimitMax, |
| 250 | "afterFields": nil, |
| 251 | "login": "monalisa", |
| 252 | "number": 1, |
| 253 | }, |
| 254 | }). |
| 255 | Reply(200). |
| 256 | JSON(map[string]interface{}{ |
| 257 | "data": map[string]interface{}{ |
| 258 | "user": map[string]interface{}{ |
| 259 | "projectV2": map[string]interface{}{ |
| 260 | "items": map[string]interface{}{ |
| 261 | "nodes": []map[string]interface{}{ |
| 262 | { |
| 263 | "id": "issue ID", |
| 264 | "content": map[string]interface{}{ |
| 265 | "__typename": "Issue", |
| 266 | "title": "an issue", |
| 267 | "number": 1, |
| 268 | "repository": map[string]string{ |
| 269 | "nameWithOwner": "cli/go-gh", |