Repository navigation
test(coderd/x/chatd): reuse recordingPubsub in the task test fixture - #30923
ibetitsmike wants to merge 2 commits into
Conversation
taskRecordingPubsub duplicated recordingPubsub with a clear method, an events snapshot and an onPublish hook. recordingPubsub now has those three, so the task fixture uses it and reaches the raw pubsub through the embedded field instead of a separate rawPS.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review
|
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
tasks_test.gokept its own copy of the recording pubsub,taskRecordingPubsub(59 lines), next torecordingPubsubinhelpers_test.go. This PR adds the three things the copy had (clear, apublishedsnapshot and anonPublishhook) torecordingPubsub, points the task fixture at it, and deletes the copy. The task fixture now reaches the raw pubsub through the embedded field, so itsrawPSfield goes too.Why it is safe
onPublishruns outside the lock and before the innerPublish,cleardrops the recorded events, andpublishedreturns a copy taken under the lock. It replaces the copy'sevents(), which would collide with the existingeventsfield.recordingPubsubembeds the fulldbpubsub.Pubsub, so subscriptions reach the same inner pubsub the copy forwardedSubscribeWithErrto. Servers built by the task helpers still get the raw pubsub.watchEventsis the existingrecordingPubsubmethod. It filters the same way the copy did, reading under the lock instead of from a snapshot.rg 'taskRecordingPubsub|taskPublishedEvent|rawPS' coderd/finds nothing.Review focus
The turn-trace tests set
f.pubsub.onPublishwhile holdingf.pubsub.mu. Both names are unchanged, andPublishstill reads the hook under that lock.Validation
I built the package test binary with
go test -c ./coderd/x/chatd/(and with-race). Ten files use either fixture:tasks_test.go,hooks_internal_test.go,turn_trace_internal_test.goand the sevenworkerTestFixturefiles. I ran the 142 top-level tests in the ten files with-test.count=1 -test.parallel 4.-racemain(e289c6fe011)The pre-commit hook passed.
Stack
The stack folds the task test fixture into the shared worker test fixture.
recordingPubsubin the task test fixture (this PR)taskTestFixtureintoworkerTestFixture