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.
This commit is contained in:
Ethan
2026-05-22 20:24:38 +10:00
committed by GitHub
parent 705421bc5d
commit c650aabbef
52 changed files with 70 additions and 64 deletions
@@ -1,4 +1,4 @@
package apidump //nolint:testpackage // tests unexported internals
package apidump
import (
"bytes"
@@ -1,4 +1,4 @@
package apidump //nolint:testpackage // tests unexported internals
package apidump
import (
"bytes"
@@ -1,4 +1,4 @@
package apidump //nolint:testpackage // shares test helpers with apidump_test.go
package apidump
import (
"bytes"
@@ -1,4 +1,4 @@
package chatcompletions //nolint:testpackage // tests unexported internals
package chatcompletions
import (
"context"
@@ -1,4 +1,4 @@
package chatcompletions //nolint:testpackage // tests unexported internals
package chatcompletions
import (
"context"
@@ -1,4 +1,4 @@
package chatcompletions //nolint:testpackage // tests unexported internals
package chatcompletions
import (
"fmt"
@@ -1,4 +1,4 @@
package chatcompletions //nolint:testpackage // tests unexported internals
package chatcompletions
import (
"io"
@@ -1,4 +1,4 @@
package messages //nolint:testpackage // tests unexported internals
package messages
import (
"context"
@@ -1,4 +1,4 @@
package messages //nolint:testpackage // tests unexported internals
package messages
import (
"io"
@@ -1,4 +1,4 @@
package messages //nolint:testpackage // tests unexported internals
package messages
import (
"testing"
@@ -1,4 +1,4 @@
package messages //nolint:testpackage // tests unexported internals
package messages
import (
"context"
@@ -1,4 +1,4 @@
package responses //nolint:testpackage // tests unexported internals
package responses
import (
"context"
@@ -1,4 +1,4 @@
package responses //nolint:testpackage // tests unexported internals
package responses
import (
"context"
@@ -1,4 +1,4 @@
package responses //nolint:testpackage // tests unexported internals
package responses
import (
"encoding/json"
@@ -1,4 +1,4 @@
package responses //nolint:testpackage // tests unexported internals
package responses
import (
"io"
@@ -1,4 +1,4 @@
package integrationtest //nolint:testpackage // tests unexported internals
package integrationtest
import (
"bufio"
@@ -1,4 +1,4 @@
package integrationtest //nolint:testpackage // tests unexported internals
package integrationtest
import (
"bytes"
@@ -1,4 +1,4 @@
package integrationtest //nolint:testpackage // tests unexported internals
package integrationtest
import (
"fmt"
@@ -1,4 +1,4 @@
package integrationtest //nolint:testpackage // tests unexported internals
package integrationtest
import (
"fmt"
@@ -1,4 +1,4 @@
package integrationtest //nolint:testpackage // tests unexported internals
package integrationtest
import (
"bytes"
@@ -1,4 +1,4 @@
package integrationtest //nolint:testpackage // tests unexported internals
package integrationtest
import (
"context"
@@ -1,4 +1,4 @@
package integrationtest //nolint:testpackage // tests unexported internals
package integrationtest
import (
"context"
@@ -1,4 +1,4 @@
package aibridge //nolint:testpackage // tests unexported newPassthroughRouter
package aibridge
import (
"crypto/tls"
@@ -1,4 +1,4 @@
package provider //nolint:testpackage // tests unexported internals
package provider
import (
"bytes"
@@ -1,4 +1,4 @@
package provider //nolint:testpackage // tests unexported internals
package provider
import (
"bytes"
@@ -1,4 +1,4 @@
package provider //nolint:testpackage // tests unexported internals
package provider
import (
"bytes"