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

Function TestWatchRun

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

Source from the content-addressed store, hash-verified

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