Skip to content

test(cmd): funnel goroutine results to test goroutine in alias test#1239

Open
cristim wants to merge 1 commit into
mainfrom
test/test-06-fix
Open

test(cmd): funnel goroutine results to test goroutine in alias test#1239
cristim wants to merge 1 commit into
mainfrom
test/test-06-fix

Conversation

@cristim

@cristim cristim commented Jun 11, 2026

Copy link
Copy Markdown
Member

Problem

Code-review finding TEST-06 (P3, issue #1159): in TestGetAccountAliasConcurrency (cmd/helpers_test.go), 10 worker goroutines each called assert.Equal(t, ...) directly. Only the test goroutine may call assert/require; the current join via a done channel prevents a post-completion race today, but the pattern is fragile: upgrading assert to require inside a goroutine, or removing the join, turns failures into lost reports or post-test panics.

Fix

Workers now send their GetAccountAlias results over a buffered results channel and only the test goroutine asserts, after wg.Wait() and close(results). This matches the established errCh pattern used in internal/server/scheduledauth/validator_test.go and internal/auth/service_user_test.go. The goroutine count is a named constant (numGoroutines) instead of a repeated literal.

Test evidence

  • go build ./... passes
  • go test -race -run TestGetAccountAlias ./cmd/ passes (6 tests)
  • go test -race ./cmd/ passes (733 tests)

This is a test-hygiene refactor of an existing test; the mock single-call invariant (mockOrg.AssertExpectations) and the double-checked-locking coverage are unchanged.

Closes #1159

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/xs Trivial / one-liner type/chore Maintenance / non-user-visible labels Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 6 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c95a634-fab8-4d96-a1c7-5d2d431f76c4

📥 Commits

Reviewing files that changed from the base of the PR and between 451a70f and ba55b3c.

📒 Files selected for processing (1)
  • cmd/helpers_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/test-06-fix

Comment @coderabbitai help to get the list of available commands.

@cristim

cristim commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

TestGetAccountAliasConcurrency had 10 worker goroutines each calling
assert.Equal directly. Only the test goroutine may call assert/require;
calling them from workers risks lost failures or post-test panics if
the join is ever removed or assert is upgraded to require.

Workers now send results over a buffered channel and the test goroutine
asserts after wg.Wait(), matching the errCh pattern used in
validator_test.go and service_user_test.go. Verified with
go test -race ./cmd/ (733 tests pass).

Closes #1159
@cristim cristim force-pushed the test/test-06-fix branch from 81272ae to ba55b3c Compare June 19, 2026 22:03
@cristim

cristim commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 0 minutes and 22 seconds before sending another message.

@cristim

cristim commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

(Earlier @coderabbitai review was rate-limited and skipped the commit. Requesting a full review on cmd/helpers_test.go to recover.)

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@cristim Re-running a full review now, with attention to cmd/helpers_test.go since the earlier review was rate-limited and skipped that commit.

✅ Action performed

Full review finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TEST-06: assert.Equal called from spawned worker goroutines instead of funneling failures to the test goroutine

1 participant