Summary
Test naming violations across 3 categories totaling ~77 instances. While test naming doesn't affect the public API, it impacts readability and consistency for contributors.
1. Test functions with underscores (22 instances)
Go test functions must use Test + CamelCase. The Test_ prefix and mid-name underscores are non-idiomatic.
Worst offender: prefork/prefork_test.go (9 violations):
Test_IsChild → TestIsChild
Test_New → TestNew
Test_listen → TestListen
Test_setTCPListenerFiles → TestSetTCPListenerFiles
Test_ListenAndServe → TestListenAndServe
Test_ListenAndServeTLS → TestListenAndServeTLS
Test_ListenAndServeTLSEmbed → TestListenAndServeTLSEmbed
Test_Prefork_Lifecycle → TestPreforkLifecycle
Test_Prefork_RecoveredChildSpawnError → TestPreforkRecoveredChildSpawnError
Other files:
client_test.go: Test_AddMissingPort, Test_getRedirectURL, TestClientNonIdempotentRetry_BodyStream, TestClient_RetryIfErrUpstream
header_test.go: TestRequestHeader_PeekAll, TestResponseHeader_PeekAll, TestRequestHeader_Keys, TestResponseHeader_Keys
userdata_test.go: TestUserData_GC
server_test.go: TestServerCRNLAfterPost_Pipeline
adaptor_test.go: TestResourceRecyclingUnderLoad_OneEndpoint, TestResourceRecyclingUnderLoad_MultipleEndpoints
dialer_test.go: TestDialer_GetDialFunc
2. Fuzz function with redundant Test infix (1 instance)
FuzzTestHeaderScanner → FuzzHeaderScanner (fuzz_test.go:153)
3. t.Run() subtest names with uppercase (40 instances)
Subtest names should be fully lowercase descriptive phrases, not CamelCase or title case.
Examples from cookie_test.go:
"SetKey" → "set key"
"SetValueBytes" → "set value bytes"
"SetDomain" → "set domain"
Examples from header_test.go:
"ResponseHeader" → "response header"
"RequestHeader_"+tc.name → "request header/"+tc.name
"Safe_RequestHeader_"+header → "safe request header/"+header
Examples from client_test.go:
"Path normalizing enabled..." → "path normalizing enabled..."
"Client should fail after..." → "client should fail after..."
4. t.Run() subtest names with underscores (15 instances)
Subtests should use spaces, not underscores. The / separator is idiomatic for grouping.
"buffered_too_large" → "buffered too large"
"RequestHeader_"+tc.name → "request header/"+tc.name
"Safe_RequestHeader_"+header → "safe request header/"+header
5. Table-driven test fields using want instead of expected (13 instances)
| File |
Current |
Suggested |
client_test.go |
want bool, want string |
expected bool, expected string |
header_test.go |
wantValue, wantFirstLine, wantNoHTTP11 |
expectedValue, expectedFirstLine, expectedNoHTTP11 |
fs_fs_test.go |
want bool |
expected bool |
fasthttpproxy/dialer_test.go |
wantCounts |
expectedCounts |
bytesconv_test.go |
hasError bool, roundTrip bool |
expectedError bool, expectedRoundTrip bool |
Reference
Summary
Test naming violations across 3 categories totaling ~77 instances. While test naming doesn't affect the public API, it impacts readability and consistency for contributors.
1. Test functions with underscores (22 instances)
Go test functions must use
Test+ CamelCase. TheTest_prefix and mid-name underscores are non-idiomatic.Worst offender:
prefork/prefork_test.go(9 violations):Other files:
2. Fuzz function with redundant
Testinfix (1 instance)3.
t.Run()subtest names with uppercase (40 instances)Subtest names should be fully lowercase descriptive phrases, not CamelCase or title case.
Examples from
cookie_test.go:Examples from
header_test.go:Examples from
client_test.go:4.
t.Run()subtest names with underscores (15 instances)Subtests should use spaces, not underscores. The
/separator is idiomatic for grouping.5. Table-driven test fields using
wantinstead ofexpected(13 instances)client_test.gowant bool,want stringexpected bool,expected stringheader_test.gowantValue,wantFirstLine,wantNoHTTP11expectedValue,expectedFirstLine,expectedNoHTTP11fs_fs_test.gowant boolexpected boolfasthttpproxy/dialer_test.gowantCountsexpectedCountsbytesconv_test.gohasError bool,roundTrip boolexpectedError bool,expectedRoundTrip boolReference