Merge pull request #3982 from despreston/des/err-return
Return SilentError if completed run failed
This commit is contained in:
commit
cd3df4cdf9
2 changed files with 20 additions and 7 deletions
|
|
@ -123,6 +123,9 @@ func watchRun(opts *WatchOptions) error {
|
|||
|
||||
if run.Status == shared.Completed {
|
||||
fmt.Fprintf(out, "Run %s (%s) has already completed with '%s'\n", cs.Bold(run.Name), cs.Cyanf("%d", run.ID), run.Conclusion)
|
||||
if opts.ExitStatus && run.Conclusion != shared.Success {
|
||||
return cmdutil.SilentError
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,21 @@ func TestWatchRun(t *testing.T) {
|
|||
},
|
||||
wantOut: "Run failed (1234) has already completed with 'failure'\n",
|
||||
},
|
||||
{
|
||||
name: "already completed, exit status",
|
||||
opts: &WatchOptions{
|
||||
RunID: "1234",
|
||||
ExitStatus: true,
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234"),
|
||||
httpmock.JSONResponse(shared.FailedRun))
|
||||
},
|
||||
wantOut: "Run failed (1234) has already completed with 'failure'\n",
|
||||
wantErr: true,
|
||||
errMsg: "SilentError",
|
||||
},
|
||||
{
|
||||
name: "prompt, no in progress runs",
|
||||
tty: true,
|
||||
|
|
@ -307,13 +322,8 @@ func TestWatchRun(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := watchRun(tt.opts)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, tt.errMsg, err.Error())
|
||||
if !tt.opts.ExitStatus {
|
||||
return
|
||||
}
|
||||
}
|
||||
if !tt.opts.ExitStatus {
|
||||
assert.EqualError(t, err, tt.errMsg)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
assert.Equal(t, tt.wantOut, stdout.String())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue