MCPcopy Index your code
hub / github.com/cli/cli / TestListRun

Function TestListRun

pkg/cmd/org/list/list_test.go:80–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestListRun(t *testing.T) {
81 tests := []struct {
82 name string
83 opts ListOptions
84 isTTY bool
85 wantOut string
86 }{
87 {
88 name: "no organizations found",
89 opts: ListOptions{HttpClient: func() (*http.Client, error) {
90 r := &httpmock.Registry{}
91
92 r.Register(
93 httpmock.GraphQL(`query UserCurrent\b`),
94 httpmock.StringResponse(`{"data": {"viewer": {"login": "octocat"}}}`))
95
96 r.Register(
97 httpmock.GraphQL(`query OrganizationList\b`),
98 httpmock.StringResponse(`
99 { "data": { "user": {
100 "organizations": { "nodes": [], "totalCount": 0 }
101 } } }`,
102 ),
103 )
104
105 return &http.Client{Transport: r}, nil
106 }},
107 isTTY: true,
108 wantOut: heredoc.Doc(`
109
110There are no organizations associated with @octocat
111
112`),
113 },
114 {
115 name: "default behavior",
116 opts: ListOptions{HttpClient: func() (*http.Client, error) {
117 r := &httpmock.Registry{}
118
119 r.Register(
120 httpmock.GraphQL(`query UserCurrent\b`),
121 httpmock.StringResponse(`{"data": {"viewer": {"login": "octocat"}}}`))
122
123 r.Register(
124 httpmock.GraphQL(`query OrganizationList\b`),
125 httpmock.StringResponse(`
126 { "data": { "user": { "organizations": {
127 "totalCount": 2,
128 "nodes": [
129 {
130 "login": "github"
131 },
132 {
133 "login": "cli"
134 }
135 ] } } } }`,
136 ),
137 )

Callers

nothing calls this directly

Calls 12

RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
TestFunction · 0.92
NewBlankConfigFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
listRunFunction · 0.70
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected