MCPcopy
hub / github.com/cli/cli / TestListLabels

Function TestListLabels

pkg/cmd/discussion/client/client_test.go:2722–2854  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2720}
2721
2722func 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`),

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
VerifyMethod · 0.95
NewFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
newTestDiscussionClientFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ListLabelsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected