(t *testing.T)
| 2720 | } |
| 2721 | |
| 2722 | func TestListLabels(t *testing.T) { |
| 2723 | repo := ghrepo.New("OWNER", "REPO") |
| 2724 | |
| 2725 | tests := []struct { |
| 2726 | name string |
| 2727 | httpStubs func(*httpmock.Registry) |
| 2728 | want []DiscussionLabel |
| 2729 | wantErr string |
| 2730 | }{ |
| 2731 | { |
| 2732 | name: "single page", |
| 2733 | httpStubs: func(reg *httpmock.Registry) { |
| 2734 | reg.Register( |
| 2735 | httpmock.GraphQL(`query RepositoryLabelsForDiscussions\b`), |
| 2736 | httpmock.StringResponse(heredoc.Doc(` |
| 2737 | { |
| 2738 | "data": { |
| 2739 | "repository": { |
| 2740 | "labels": { |
| 2741 | "nodes": [ |
| 2742 | {"id": "L_bug", "name": "bug", "color": "d73a4a"}, |
| 2743 | {"id": "L_enh", "name": "enhancement", "color": "a2eeef"} |
| 2744 | ], |
| 2745 | "pageInfo": {"hasNextPage": false, "endCursor": ""} |
| 2746 | } |
| 2747 | } |
| 2748 | } |
| 2749 | } |
| 2750 | `)), |
| 2751 | ) |
| 2752 | }, |
| 2753 | want: []DiscussionLabel{ |
| 2754 | {ID: "L_bug", Name: "bug", Color: "d73a4a"}, |
| 2755 | {ID: "L_enh", Name: "enhancement", Color: "a2eeef"}, |
| 2756 | }, |
| 2757 | }, |
| 2758 | { |
| 2759 | name: "multiple pages", |
| 2760 | httpStubs: func(reg *httpmock.Registry) { |
| 2761 | reg.Register( |
| 2762 | httpmock.GraphQL(`query RepositoryLabelsForDiscussions\b`), |
| 2763 | httpmock.StringResponse(heredoc.Doc(` |
| 2764 | { |
| 2765 | "data": { |
| 2766 | "repository": { |
| 2767 | "labels": { |
| 2768 | "nodes": [ |
| 2769 | {"id": "L_bug", "name": "bug", "color": "d73a4a"} |
| 2770 | ], |
| 2771 | "pageInfo": {"hasNextPage": true, "endCursor": "CUR_1"} |
| 2772 | } |
| 2773 | } |
| 2774 | } |
| 2775 | } |
| 2776 | `)), |
| 2777 | ) |
| 2778 | reg.Register( |
| 2779 | httpmock.GraphQL(`query RepositoryLabelsForDiscussions\b`), |
nothing calls this directly
no test coverage detected