Skip to content

Commit 0ee23dc

Browse files
committed
tests for exit status on job view
1 parent f845c62 commit 0ee23dc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pkg/cmd/job/view/view_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,41 @@ func TestRunView(t *testing.T) {
119119
wantErr bool
120120
wantOut string
121121
}{
122+
{
123+
name: "exit status respected with --log",
124+
opts: &ViewOptions{
125+
JobID: "20",
126+
ExitStatus: true,
127+
Log: true,
128+
},
129+
httpStubs: func(reg *httpmock.Registry) {
130+
reg.Register(
131+
httpmock.REST("GET", "repos/OWNER/REPO/actions/jobs/20"),
132+
httpmock.JSONResponse(shared.FailedJob))
133+
reg.Register(
134+
httpmock.REST("GET", "repos/OWNER/REPO/actions/jobs/20/logs"),
135+
httpmock.StringResponse("it's a log\nfor this job\nbeautiful log\n"))
136+
},
137+
wantErr: true,
138+
wantOut: "it's a log\nfor this job\nbeautiful log\n",
139+
},
140+
{
141+
name: "exit status respected",
142+
opts: &ViewOptions{
143+
JobID: "20",
144+
ExitStatus: true,
145+
},
146+
httpStubs: func(reg *httpmock.Registry) {
147+
reg.Register(
148+
httpmock.REST("GET", "repos/OWNER/REPO/actions/jobs/20"),
149+
httpmock.JSONResponse(shared.FailedJob))
150+
reg.Register(
151+
httpmock.REST("GET", "repos/OWNER/REPO/check-runs/20/annotations"),
152+
httpmock.JSONResponse(shared.FailedJobAnnotations))
153+
},
154+
wantErr: true,
155+
wantOut: "sad job (ID 20)\nX 59m ago in 4m34s\n\n✓ barf the quux\nX quux the barf\n\nANNOTATIONS\nX the job is sad\nblaze.py#420\n\n\nTo see the full logs for this job, try: gh job view 20 --log\nView this job on GitHub: jobs/20\n",
156+
},
122157
{
123158
name: "interactive flow, multi-job",
124159
tty: true,

0 commit comments

Comments
 (0)