fsjobqueue: make canceling a finished job an error
This mirrors FinishJob(), which also errors when the job is already finished.
This commit is contained in:
parent
30492bfc60
commit
871c6e9cbb
2 changed files with 4 additions and 3 deletions
|
|
@ -298,7 +298,7 @@ func (q *fsJobQueue) CancelJob(id uuid.UUID) error {
|
|||
}
|
||||
|
||||
if !j.FinishedAt.IsZero() {
|
||||
return nil
|
||||
return jobqueue.ErrNotRunning
|
||||
}
|
||||
|
||||
j.Canceled = true
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ func testCancel(t *testing.T, q jobqueue.JobQueue) {
|
|||
err = q.FinishJob(id, &testResult{})
|
||||
require.Error(t, err)
|
||||
|
||||
// Cancel a finished job, which is a no-op
|
||||
// Cancel a finished job, which is an error
|
||||
id = pushTestJob(t, q, "clownfish", nil, nil)
|
||||
require.NotEmpty(t, id)
|
||||
r, tok, deps, typ, args, err = q.Dequeue(context.Background(), []string{"clownfish"})
|
||||
|
|
@ -312,7 +312,8 @@ func testCancel(t *testing.T, q jobqueue.JobQueue) {
|
|||
err = q.FinishJob(id, &testResult{})
|
||||
require.NoError(t, err)
|
||||
err = q.CancelJob(id)
|
||||
require.NoError(t, err)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, jobqueue.ErrNotRunning, err)
|
||||
result, _, _, _, canceled, _, err = q.JobStatus(id)
|
||||
require.NoError(t, err)
|
||||
require.False(t, canceled)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue