| 400 | } |
| 401 | |
| 402 | func TestRunListViewer(t *testing.T) { |
| 403 | defer gock.Off() |
| 404 | gock.Observe(gock.DumpRequest) |
| 405 | |
| 406 | // get viewer ID |
| 407 | gock.New("https://api.github.com"). |
| 408 | Post("/graphql"). |
| 409 | MatchType("json"). |
| 410 | JSON(map[string]interface{}{ |
| 411 | "query": "query ViewerOwner.*", |
| 412 | }). |
| 413 | Reply(200). |
| 414 | JSON(map[string]interface{}{ |
| 415 | "data": map[string]interface{}{ |
| 416 | "viewer": map[string]interface{}{ |
| 417 | "id": "an ID", |
| 418 | }, |
| 419 | }, |
| 420 | }) |
| 421 | |
| 422 | gock.New("https://api.github.com"). |
| 423 | Post("/graphql"). |
| 424 | Reply(200). |
| 425 | JSON(map[string]interface{}{ |
| 426 | "data": map[string]interface{}{ |
| 427 | "viewer": map[string]interface{}{ |
| 428 | "login": "monalisa", |
| 429 | "projectsV2": map[string]interface{}{ |
| 430 | "nodes": []interface{}{ |
| 431 | map[string]interface{}{ |
| 432 | "title": "Project 1", |
| 433 | "shortDescription": "Short description 1", |
| 434 | "url": "url1", |
| 435 | "closed": false, |
| 436 | "ID": "id-1", |
| 437 | "number": 1, |
| 438 | }, |
| 439 | map[string]interface{}{ |
| 440 | "title": "Project 2", |
| 441 | "shortDescription": "", |
| 442 | "url": "url2", |
| 443 | "closed": true, |
| 444 | "ID": "id-2", |
| 445 | "number": 2, |
| 446 | }, |
| 447 | }, |
| 448 | }, |
| 449 | }, |
| 450 | }, |
| 451 | }) |
| 452 | |
| 453 | client := queries.NewTestClient() |
| 454 | |
| 455 | ios, _, stdout, _ := iostreams.Test() |
| 456 | config := listConfig{ |
| 457 | opts: listOpts{}, |
| 458 | client: client, |
| 459 | io: ios, |