-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing integration-level job snooze test #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, sorry I missed this coverage but thank you for adding it.
AddWorker(client.config.Workers, WorkFunc(func(ctx context.Context, job *Job[JobArgs]) error { | ||
return JobCancel(fmt.Errorf("a persisted internal error")) | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check the job in the database after this is all done for completeness? i.e. make sure it is cancelled and the error is saved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Added.
AddWorker(client.config.Workers, WorkFunc(func(ctx context.Context, job *Job[JobArgs]) error { | ||
return JobSnooze(15 * time.Minute) | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, should we check anything about the job in the DB after this executes? Since this is an integration test it might be a good safety check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
I noticed while trying to refactor something the other day that I had a problem around snoozing, but only the example snooze test was failing. Looking into it further, it turned out that it was because the snooze example was the only snooze test we had. Example tests aren't great because they do obnoxious things like swallow all output (making it harder to debug), but they also don't support some feature like `-count`, making it harder to debug intermittent problems. Here, add another client test for snooze. We use the new client test line that makes use of `JobArgsReflectKind` and `WorkFunc`, keeping the implementation clean and all local to the specific test case that needs it. And since snooze and cancel are quite similar, I added a test case for cancel as well. Cancel did have another test elsewhere, but I figure I might as well add one in this new line too to line up with the snooze test case. It should be a pretty fast test, so doesn't hurt to have a duplicate.
7f94356
to
ce5f5da
Compare
I noticed while trying to refactor something the other day that I had a
problem around snoozing, but only the example snooze test was failing.
Looking into it further, it turned out that it was because the snooze
example was the only snooze test we had.
Example tests aren't great because they do obnoxious things like swallow
all output (making it harder to debug), but they also don't support some
feature like
-count
, making it harder to debug intermittent problems.Here, add another client test for snooze. We use the new client test
line that makes use of
JobArgsReflectKind
andWorkFunc
, keeping theimplementation clean and all local to the specific test case that needs
it.
And since snooze and cancel are quite similar, I added a test case for
cancel as well. Cancel did have another test elsewhere, but I figure I
might as well add one in this new line too to line up with the snooze
test case. It should be a pretty fast test, so doesn't hurt to have a
duplicate.