(t *testing.T)
| 163 | } |
| 164 | |
| 165 | func 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), |
nothing calls this directly
no test coverage detected