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:
parent
c319960bbb
commit
80bd617378
|
|
@ -16,13 +16,49 @@ func TestEnvCallbackScalarAndAliases(t *testing.T) {
|
||||||
wantKey string
|
wantKey string
|
||||||
wantVal any
|
wantVal any
|
||||||
}{
|
}{
|
||||||
{"mysql fake enabled alias", "MYSQL_FAKE_ENABLED", "true", "mysql.enabled", "true"},
|
{
|
||||||
{"mysql canonical enabled", "MYSQL_ENABLED", "true", "mysql.enabled", "true"},
|
"mysql fake enabled alias",
|
||||||
{"mysql fake addr alias", "MYSQL_FAKE_ADDR", "0.0.0.0:33306", "mysql.addr", "0.0.0.0:33306"},
|
"MYSQL_FAKE_ENABLED",
|
||||||
{"turnstile secret alias", "TURNSTILE_SECRET", "sk", "turnstile.secret_key", "sk"},
|
"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},
|
{"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 {
|
for _, c := range cases {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
|
|
@ -44,15 +80,31 @@ func TestEnvCallbackSliceSplitting(t *testing.T) {
|
||||||
want []string
|
want []string
|
||||||
}{
|
}{
|
||||||
{"single", "10.0.0.0/8", []string{"10.0.0.0/8"}},
|
{"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"}},
|
"multiple",
|
||||||
{"empty entries dropped", "10.0.0.0/8,,192.168.0.0/16,", []string{"10.0.0.0/8", "192.168.0.0/16"}},
|
"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 {
|
for _, c := range cases {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
gotKey, gotVal := envCallback("TRUSTED_PROXY_CIDRS", c.value)
|
gotKey, gotVal := envCallback("TRUSTED_PROXY_CIDRS", c.value)
|
||||||
if gotKey != "server.trusted_proxy_cidrs" {
|
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)
|
got, ok := gotVal.([]string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue