Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[go] Show how to test a worker that uses JobCompleteTx - #1604

Open
yudongyouqing wants to merge 3 commits into
riverqueue:masterfrom
yudongyouqing:go/example-job-complete-tx-test
Open

yudongyouqing wants to merge 3 commits into
riverqueue:masterfrom
yudongyouqing:go/example-job-complete-tx-test

Conversation

@yudongyouqing

Copy link
Copy Markdown

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_completeJobWithinTx keeps
being shown as a whole file example.

Verification

  • go test -count=1 -v . -run '^(Example_completeJobWithinTx|TestTransactionalWorker)$' — both pass
  • go test -count=1 -v ./rivertest -run '^TestWorker_WorkJob$/^JobCompleteTxWithInsertedJobRow$' — passes
  • Negative control: with the JobCompleteTx call removed, TestTransactionalWorker
    fails with got "running", want "completed"
  • golangci-lint run v2.14.0 — 0 issues

AI assistance

Implemented by GLM (Claude Code) from a plan written with Codex, which also
reviewed the diff.

🤖 Generated with Claude Code

yudongyouqing and others added 3 commits November 22, 2026 22:32
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant