MCPcopy
hub / github.com/cli/cli / Test_listRun

Function Test_listRun

pkg/cmd/gist/list/list_test.go:132–650  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

130}
131
132func Test_listRun(t *testing.T) {
133 const query = `query GistList\b`
134 sixHours, _ := time.ParseDuration("6h")
135 sixHoursAgo := time.Now().Add(-sixHours)
136 absTime, _ := time.Parse(time.RFC3339, "2020-07-30T15:24:28Z")
137
138 tests := []struct {
139 name string
140 opts *ListOptions
141 wantErr bool
142 wantOut string
143 stubs func(*httpmock.Registry)
144 color bool
145 nontty bool
146 }{
147 {
148 name: "no gists",
149 opts: &ListOptions{},
150 stubs: func(reg *httpmock.Registry) {
151 reg.Register(
152 httpmock.GraphQL(query),
153 httpmock.StringResponse(`{ "data": { "viewer": {
154 "gists": { "nodes": [] }
155 } } }`))
156 },
157 wantErr: true,
158 },
159 {
160 name: "default behavior",
161 opts: &ListOptions{},
162 stubs: func(reg *httpmock.Registry) {
163 reg.Register(
164 httpmock.GraphQL(query),
165 httpmock.StringResponse(fmt.Sprintf(
166 `{ "data": { "viewer": { "gists": { "nodes": [
167 {
168 "name": "1234567890",
169 "files": [{ "name": "cool.txt" }],
170 "description": "",
171 "updatedAt": "%[1]v",
172 "isPublic": true
173 },
174 {
175 "name": "4567890123",
176 "files": [{ "name": "gistfile0.txt" }],
177 "description": "",
178 "updatedAt": "%[1]v",
179 "isPublic": true
180 },
181 {
182 "name": "2345678901",
183 "files": [
184 { "name": "gistfile0.txt" },
185 { "name": "gistfile1.txt" }
186 ],
187 "description": "tea leaves thwart those who court catastrophe",
188 "updatedAt": "%[1]v",
189 "isPublic": false

Callers

nothing calls this directly

Calls 14

RegisterMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewBlankConfigFunction · 0.92
TestFunction · 0.92
SetColorEnabledMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
listRunFunction · 0.70
AddMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected