MCPcopy
hub / github.com/cli/cli / TestViewRun

Function TestViewRun

pkg/cmd/workflow/view/view_test.go:165–432  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestViewRun(t *testing.T) {
166 aWorkflow := shared.Workflow{
167 Name: "a workflow",
168 ID: 123,
169 Path: ".github/workflows/flow.yml",
170 State: shared.Active,
171 }
172 aWorkflowContent := `{"content":"bmFtZTogYSB3b3JrZmxvdwo="}`
173 aWorkflowInfo := heredoc.Doc(`
174 a workflow - flow.yml
175 ID: 123
176
177 Total runs 10
178 Recent runs
179 TITLE WORKFLOW BRANCH EVENT ID
180 X cool commit a workflow trunk push 1
181 * cool commit a workflow trunk push 2
182 ✓ cool commit a workflow trunk push 3
183 X cool commit a workflow trunk push 4
184
185 To see more runs for this workflow, try: gh run list --workflow flow.yml
186 To see the YAML for this workflow, try: gh workflow view flow.yml --yaml
187 `)
188
189 tests := []struct {
190 name string
191 opts *ViewOptions
192 httpStubs func(*httpmock.Registry)
193 tty bool
194 wantOut string
195 wantErrOut string
196 wantErr bool
197 }{
198 {
199 name: "no enabled workflows",
200 tty: true,
201 opts: &ViewOptions{
202 Prompt: true,
203 },
204 httpStubs: func(reg *httpmock.Registry) {
205 reg.Register(
206 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
207 httpmock.JSONResponse(shared.WorkflowsPayload{}))
208 },
209 wantErrOut: "could not fetch workflows for OWNER/REPO: no workflows are enabled",
210 wantErr: true,
211 },
212 {
213 name: "web",
214 tty: true,
215 opts: &ViewOptions{
216 Selector: "123",
217 Web: true,
218 },
219 httpStubs: func(reg *httpmock.Registry) {
220 reg.Register(
221 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
222 httpmock.JSONResponse(aWorkflow),

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected