MCPcopy
hub / github.com/cli/cli / TestWatchRun

Function TestWatchRun

pkg/cmd/run/watch/watch_test.go:110–418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestWatchRun(t *testing.T) {
111 failedRunStubs := func(reg *httpmock.Registry) {
112 inProgressRun := shared.TestRunWithCommit(2, shared.InProgress, "", "commit2")
113 completedRun := shared.TestRun(2, shared.Completed, shared.Failure)
114 reg.Register(
115 httpmock.REST("GET", "repos/OWNER/REPO/actions/runs"),
116 httpmock.JSONResponse(shared.RunsPayload{
117 WorkflowRuns: []shared.Run{
118 shared.TestRunWithCommit(1, shared.InProgress, "", "commit1"),
119 inProgressRun,
120 },
121 }))
122 reg.Register(
123 httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/2"),
124 httpmock.JSONResponse(inProgressRun))
125 reg.Register(
126 httpmock.REST("GET", "runs/2/jobs"),
127 httpmock.JSONResponse(shared.JobsPayload{
128 Jobs: []shared.Job{}}))
129 reg.Register(
130 httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/2"),
131 httpmock.JSONResponse(completedRun))
132 reg.Register(
133 httpmock.REST("GET", "runs/2/jobs"),
134 httpmock.JSONResponse(shared.JobsPayload{
135 Jobs: []shared.Job{
136 shared.FailedJob,
137 },
138 }))
139 reg.Register(
140 httpmock.REST("GET", "repos/OWNER/REPO/check-runs/20/annotations"),
141 httpmock.JSONResponse(shared.FailedJobAnnotations))
142 reg.Register(
143 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
144 httpmock.JSONResponse(workflowShared.WorkflowsPayload{
145 Workflows: []workflowShared.Workflow{
146 shared.TestWorkflow,
147 },
148 }))
149 reg.Register(
150 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
151 httpmock.JSONResponse(shared.TestWorkflow))
152 reg.Register(
153 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
154 httpmock.JSONResponse(shared.TestWorkflow))
155 }
156 successfulRunStubs := func(reg *httpmock.Registry) {
157 inProgressRun := shared.TestRunWithCommit(2, shared.InProgress, "", "commit2")
158 completedRun := shared.TestRun(2, shared.Completed, shared.Success)
159 reg.Register(
160 httpmock.REST("GET", "repos/OWNER/REPO/actions/runs"),
161 httpmock.JSONResponse(shared.RunsPayload{
162 WorkflowRuns: []shared.Run{
163 shared.TestRunWithCommit(1, shared.InProgress, "", "commit1"),
164 inProgressRun,
165 },
166 }))
167 reg.Register(

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
IndexForFunction · 0.92
JSONErrorResponseFunction · 0.92
StatusStringResponseFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
NewMockPrompterFunction · 0.92
watchRunFunction · 0.85
SetStdoutTTYMethod · 0.80

Tested by

no test coverage detected