Skip to content

Commit c650aab

Browse files
chore: standardize on *_internal_test.go for white-box tests (#25601)
My agent added `//nolint:testpackage` to a test file on one of my PRs. Again. This PR cleans it up across the entire repo and updates the in-repo conventions so future agents stop doing it. The repo already has a precedent for white-box tests that need to touch unexported symbols: `*_internal_test.go` (145+ existing files). The `testpackage` linter's default `skip-regexp` exempts that filename suffix, so the `//nolint:testpackage` directive is unnecessary in every case where someone reached for it. This PR renames 51 such files to `*_internal_test.go` via `git mv` so blame and history follow, and strips the dead directive from 2 files that were already correctly named (`coderd/oauth2provider/authorize_internal_test.go`, `coderd/x/chatd/advisor_internal_test.go`). `.claude/docs/TESTING.md` now documents the rule explicitly under *Test Package Naming*, which is imported into the root `AGENTS.md` via `@.claude/docs/TESTING.md`. The rule: prefer `package foo_test`; if you need internal access, rename the file to `*_internal_test.go` rather than adding a nolint directive.
1 parent 705421b commit c650aab

52 files changed

Lines changed: 70 additions & 64 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/docs/TESTING.md

Lines changed: 23 additions & 13 deletions

agent/reconnectingpty/reconnectingpty_test.go renamed to agent/reconnectingpty/reconnectingpty_internal_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//nolint:testpackage // Tests private env helpers directly.
21
package reconnectingpty
32

43
import (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package agent //nolint:testpackage // Exercises internal agent secrets handling.
1+
package agent
22

33
import (
44
"testing"

aibridge/intercept/apidump/apidump_test.go renamed to aibridge/intercept/apidump/apidump_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apidump //nolint:testpackage // tests unexported internals
1+
package apidump
22

33
import (
44
"bytes"

aibridge/intercept/apidump/headers_test.go renamed to aibridge/intercept/apidump/headers_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apidump //nolint:testpackage // tests unexported internals
1+
package apidump
22

33
import (
44
"bytes"

aibridge/intercept/apidump/streaming_test.go renamed to aibridge/intercept/apidump/streaming_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package apidump //nolint:testpackage // shares test helpers with apidump_test.go
1+
package apidump
22

33
import (
44
"bytes"

aibridge/intercept/chatcompletions/base_test.go renamed to aibridge/intercept/chatcompletions/base_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package chatcompletions //nolint:testpackage // tests unexported internals
1+
package chatcompletions
22

33
import (
44
"context"

aibridge/intercept/chatcompletions/blocking_test.go renamed to aibridge/intercept/chatcompletions/blocking_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package chatcompletions //nolint:testpackage // tests unexported internals
1+
package chatcompletions
22

33
import (
44
"context"

aibridge/intercept/chatcompletions/paramswrap_test.go renamed to aibridge/intercept/chatcompletions/paramswrap_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package chatcompletions //nolint:testpackage // tests unexported internals
1+
package chatcompletions
22

33
import (
44
"fmt"

aibridge/intercept/chatcompletions/streaming_test.go renamed to aibridge/intercept/chatcompletions/streaming_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package chatcompletions //nolint:testpackage // tests unexported internals
1+
package chatcompletions
22

33
import (
44
"io"

0 commit comments

Comments
 (0)