cmd/vet: add subtestnames analyzer; fix all existing violations
Add a new vet analyzer that checks t.Run subtest names don't contain characters requiring quoting when re-running via "go test -run". This enforces the style guide rule: don't use spaces or punctuation in subtest names. The analyzer flags: - Direct t.Run calls with string literal names containing spaces, regex metacharacters, quotes, or other problematic characters - Table-driven t.Run(tt.name, ...) calls where tt ranges over a slice/map literal with bad name field values Also fix all 978 existing violations across 81 test files, replacing spaces with hyphens and shortening long sentence-like names to concise hyphenated forms. Updates #19242 Change-Id: Ib0ad96a111bd8e764582d1d4902fe2599454ab65 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
0f02c20c5e
commit
5ef3713c9f
@@ -28,32 +28,32 @@ func TestServerEndpointJSONUnmarshal(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "invalid ServerDisco",
|
||||
name: "invalid-ServerDisco",
|
||||
json: []byte(`{"ServerDisco":"1","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid LamportID",
|
||||
name: "invalid-LamportID",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":1.1,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid AddrPorts",
|
||||
name: "invalid-AddrPorts",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid VNI",
|
||||
name: "invalid-VNI",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":18446744073709551615,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid BindLifetime",
|
||||
name: "invalid-BindLifetime",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"5","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid SteadyStateLifetime",
|
||||
name: "invalid-SteadyStateLifetime",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
@@ -79,7 +79,7 @@ func TestServerEndpointJSONMarshal(t *testing.T) {
|
||||
serverEndpoint ServerEndpoint
|
||||
}{
|
||||
{
|
||||
name: "valid roundtrip",
|
||||
name: "valid-roundtrip",
|
||||
serverEndpoint: ServerEndpoint{
|
||||
ServerDisco: key.NewDisco().Public(),
|
||||
LamportID: uint64(math.MaxUint64),
|
||||
|
||||
@@ -196,15 +196,15 @@ func TestServer(t *testing.T) {
|
||||
forceClientsMixedAF bool
|
||||
}{
|
||||
{
|
||||
name: "over ipv4",
|
||||
name: "over-ipv4",
|
||||
staticAddrs: []netip.Addr{netip.MustParseAddr("127.0.0.1")},
|
||||
},
|
||||
{
|
||||
name: "over ipv6",
|
||||
name: "over-ipv6",
|
||||
staticAddrs: []netip.Addr{netip.MustParseAddr("::1")},
|
||||
},
|
||||
{
|
||||
name: "mixed address families",
|
||||
name: "mixed-address-families",
|
||||
staticAddrs: []netip.Addr{netip.MustParseAddr("127.0.0.1"), netip.MustParseAddr("::1")},
|
||||
forceClientsMixedAF: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user