Skip to content

Commit

Permalink
always wait for client to be healthy before testing Cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
bgentry committed Jan 13, 2024
1 parent 1ece72f commit 31ab35d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,8 @@ func (c *Client[TTx]) runProducers(fetchNewWorkCtx, workCtx context.Context) {
// usual.
//
// In the event the running job finishes executing _before_ the cancellation
// signal is received but _after_ this update was made, the behavior depends
// on which state the job is being transitioned into:
// signal is received but _after_ this update was made, the behavior depends on
// which state the job is being transitioned into (based on its return error):
//
// - If the job completed successfully, was cancelled from within, or was
// discarded due to exceeding its max attempts, the job will be updated as
Expand Down Expand Up @@ -1017,8 +1017,8 @@ func (c *Client[TTx]) Cancel(ctx context.Context, jobID int64) (*rivertype.JobRo
// usual.
//
// In the event the running job finishes executing _before_ the cancellation
// signal is received but _after_ this update was made, the behavior depends
// on which state the job is being transitioned into:
// signal is received but _after_ this update was made, the behavior depends on
// which state the job is being transitioned into (based on its return error):
//
// - If the job completed successfully, was cancelled from within, or was
// discarded due to exceeding its max attempts, the job will be updated as
Expand Down
2 changes: 2 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ func Test_Client(t *testing.T) {
return ctx.Err()
}))

statusUpdateCh := client.monitor.RegisterUpdates()
startClient(ctx, t, client)
waitForClientHealthy(ctx, t, statusUpdateCh)

insertedJob, err := client.Insert(ctx, &JobArgs{}, nil)
require.NoError(t, err)
Expand Down

0 comments on commit 31ab35d

Please sign in to comment.