MCPcopy Create free account
hub / github.com/cli/cli / TestWatchRun

Function TestWatchRun

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

Source from the content-addressed store, hash-verified

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