(t *testing.T)
| 676 | } |
| 677 | |
| 678 | func TestRunListWeb_User(t *testing.T) { |
| 679 | defer gock.Off() |
| 680 | gock.Observe(gock.DumpRequest) |
| 681 | // get user ID |
| 682 | gock.New("https://api.github.com"). |
| 683 | Post("/graphql"). |
| 684 | MatchType("json"). |
| 685 | JSON(map[string]interface{}{ |
| 686 | "query": "query UserOrgOwner.*", |
| 687 | "variables": map[string]interface{}{ |
| 688 | "login": "monalisa", |
| 689 | }, |
| 690 | }). |
| 691 | Reply(200). |
| 692 | JSON(map[string]interface{}{ |
| 693 | "data": map[string]interface{}{ |
| 694 | "user": map[string]interface{}{ |
| 695 | "id": "an ID", |
| 696 | }, |
| 697 | }, |
| 698 | "errors": []interface{}{ |
| 699 | map[string]interface{}{ |
| 700 | "type": "NOT_FOUND", |
| 701 | "path": []string{"organization"}, |
| 702 | }, |
| 703 | }, |
| 704 | }) |
| 705 | |
| 706 | client := queries.NewTestClient() |
| 707 | buf := bytes.Buffer{} |
| 708 | config := listConfig{ |
| 709 | opts: listOpts{ |
| 710 | owner: "monalisa", |
| 711 | web: true, |
| 712 | }, |
| 713 | URLOpener: func(url string) error { |
| 714 | buf.WriteString(url) |
| 715 | return nil |
| 716 | }, |
| 717 | client: client, |
| 718 | } |
| 719 | |
| 720 | err := runList(config) |
| 721 | assert.NoError(t, err) |
| 722 | assert.Equal(t, "https://github.com/users/monalisa/projects", buf.String()) |
| 723 | } |
| 724 | |
| 725 | func TestRunListWeb_Org(t *testing.T) { |
| 726 | defer gock.Off() |
nothing calls this directly
no test coverage detected