Repository navigation
[go] Show how to test a worker that uses JobCompleteTx - #1604
Open
yudongyouqing wants to merge 3 commits into
Open
yudongyouqing wants to merge 3 commits into
yudongyouqing wants to merge 3 commits into
Conversation
Extend the transactional completion example with a runnable worker test. The same worker begins a transaction from a pool in the production example and a savepoint from the test transaction in the test. The test reads the completed job before the worker returns and checks the resulting event. Related to riverqueue#605. Co-Authored-By: Claude Code <noreply@anthropic.com>
A test function in the same file stops go/doc from presenting the whole file as the example, which dropped the worker definition from the rendered documentation. Move TestTransactionalWorker to its own file. Co-Authored-By: Claude Code <noreply@anthropic.com>
AGENTS.md asks for types to be sorted alphabetically by name. transactionBeginner sorts after the Transactional* types, so declare it after TransactionalWorker and its method. Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #605.
Extend the transactional completion example with a runnable worker test.
The same worker begins a transaction from a pool in the production example
and a savepoint from the test transaction in the test. The test reads the
completed job before the worker returns and checks the resulting event.
The test lives in its own file so that
Example_completeJobWithinTxkeepsbeing shown as a whole file example.
Verification
go test -count=1 -v . -run '^(Example_completeJobWithinTx|TestTransactionalWorker)$'— both passgo test -count=1 -v ./rivertest -run '^TestWorker_WorkJob$/^JobCompleteTxWithInsertedJobRow$'— passesJobCompleteTxcall removed,TestTransactionalWorkerfails with
got "running", want "completed"golangci-lint runv2.14.0 — 0 issuesAI assistance
Implemented by GLM (Claude Code) from a plan written with Codex, which also
reviewed the diff.
🤖 Generated with Claude Code