From 31ab35d49f5d1a35443b0f1ea65f6e6fbecd0c3e Mon Sep 17 00:00:00 2001 From: Blake Gentry Date: Wed, 10 Jan 2024 09:25:03 -0600 Subject: [PATCH] always wait for client to be healthy before testing Cancel --- client.go | 8 ++++---- client_test.go | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index a5e34432..6e35d5fb 100644 --- a/client.go +++ b/client.go @@ -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 @@ -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 diff --git a/client_test.go b/client_test.go index c5ed4862..d54ff1c2 100644 --- a/client_test.go +++ b/client_test.go @@ -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)