style(canary): format config_test.go with golines (max-len 80)

Vertically wrap the long table-driven case literals and one Fatalf call to
satisfy the project's golines linter (max-len 80, reformat-tags), which the CI
Go lint job flagged. Formatting only; no test behavior change.
This commit is contained in:
CarterPerez-dev 2026-07-19 03:18:17 -04:00
parent c319960bbb
commit 80bd617378
1 changed files with 62 additions and 10 deletions

View File

@ -16,13 +16,49 @@ func TestEnvCallbackScalarAndAliases(t *testing.T) {
wantKey string
wantVal any
}{
{"mysql fake enabled alias", "MYSQL_FAKE_ENABLED", "true", "mysql.enabled", "true"},
{"mysql canonical enabled", "MYSQL_ENABLED", "true", "mysql.enabled", "true"},
{"mysql fake addr alias", "MYSQL_FAKE_ADDR", "0.0.0.0:33306", "mysql.addr", "0.0.0.0:33306"},
{"turnstile secret alias", "TURNSTILE_SECRET", "sk", "turnstile.secret_key", "sk"},
{
"mysql fake enabled alias",
"MYSQL_FAKE_ENABLED",
"true",
"mysql.enabled",
"true",
},
{
"mysql canonical enabled",
"MYSQL_ENABLED",
"true",
"mysql.enabled",
"true",
},
{
"mysql fake addr alias",
"MYSQL_FAKE_ADDR",
"0.0.0.0:33306",
"mysql.addr",
"0.0.0.0:33306",
},
{
"turnstile secret alias",
"TURNSTILE_SECRET",
"sk",
"turnstile.secret_key",
"sk",
},
{"unmapped key dropped", "SOME_RANDOM_VAR", "x", "", nil},
{"blank slice dropped keeps default", "TRUSTED_PROXY_CIDRS", "", "", nil},
{"whitespace-only slice dropped", "TRUSTED_PROXY_CIDRS", " , ,", "", nil},
{
"blank slice dropped keeps default",
"TRUSTED_PROXY_CIDRS",
"",
"",
nil,
},
{
"whitespace-only slice dropped",
"TRUSTED_PROXY_CIDRS",
" , ,",
"",
nil,
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
@ -44,15 +80,31 @@ func TestEnvCallbackSliceSplitting(t *testing.T) {
want []string
}{
{"single", "10.0.0.0/8", []string{"10.0.0.0/8"}},
{"multiple", "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16", []string{"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"}},
{"spaces trimmed", " 10.0.0.0/8 , 172.16.0.0/12 ", []string{"10.0.0.0/8", "172.16.0.0/12"}},
{"empty entries dropped", "10.0.0.0/8,,192.168.0.0/16,", []string{"10.0.0.0/8", "192.168.0.0/16"}},
{
"multiple",
"10.0.0.0/8,172.16.0.0/12,192.168.0.0/16",
[]string{"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"},
},
{
"spaces trimmed",
" 10.0.0.0/8 , 172.16.0.0/12 ",
[]string{"10.0.0.0/8", "172.16.0.0/12"},
},
{
"empty entries dropped",
"10.0.0.0/8,,192.168.0.0/16,",
[]string{"10.0.0.0/8", "192.168.0.0/16"},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
gotKey, gotVal := envCallback("TRUSTED_PROXY_CIDRS", c.value)
if gotKey != "server.trusted_proxy_cidrs" {
t.Fatalf("key: got %q, want %q", gotKey, "server.trusted_proxy_cidrs")
t.Fatalf(
"key: got %q, want %q",
gotKey,
"server.trusted_proxy_cidrs",
)
}
got, ok := gotVal.([]string)
if !ok {