test: consolidate Go tests (#39962)

Consolidate all Go tests. Coverage is identical to before. Go tests are
around 5% faster while being 7% smaller. No non-test code is touched.
This commit is contained in:
silverwind authored and GitHub committed 2026-10-24 13:48:19 +00:00
1 parent ce7364e215
commit 8abda62312
388 files changed
+18410 -29561

No files matched your search

+16 -86
View File
@@ -8,92 +8,22 @@ import (
)
func Test_ValidURLValidation(t *testing.T) {
urlValidationTestCases := []validationTestCase{
{
description: "Empty URL",
data: &TestForm{
URL: "",
},
},
{
description: "URL without port",
data: &TestForm{
URL: "http://test.lan/",
},
},
{
description: "URL with port",
data: &TestForm{
URL: "http://test.lan:3000/",
},
},
{
description: "URL with IPv6 address without port",
data: &TestForm{
URL: "http://[::1]/",
},
},
{
description: "URL with IPv6 address with port",
data: &TestForm{
URL: "http://[::1]:3000/",
},
},
{
description: "Invalid URL",
data: &TestForm{
URL: "http//test.lan/",
},
expectedErrors: BindingErrors{
BindingError{
FieldNames: []string{"URL"},
Classification: "UrlError",
Message: "Url",
},
},
},
{
description: "Invalid schema",
data: &TestForm{
URL: "ftp://test.lan/",
},
expectedErrors: BindingErrors{
BindingError{
FieldNames: []string{"URL"},
Classification: "UrlError",
Message: "Url",
},
},
},
{
description: "Invalid port",
data: &TestForm{
URL: "http://test.lan:3x4/",
},
expectedErrors: BindingErrors{
BindingError{
FieldNames: []string{"URL"},
Classification: "UrlError",
Message: "Url",
},
},
},
{
description: "Invalid port with IPv6 address",
data: &TestForm{
URL: "http://[::1]:3x4/",
},
expectedErrors: BindingErrors{
BindingError{
FieldNames: []string{"URL"},
Classification: "UrlError",
Message: "Url",
},
},
},
}
for _, testCase := range urlValidationTestCases {
expectedErrors := BindingErrors{{
FieldNames: []string{"URL"},
Classification: "UrlError",
Message: "Url",
}}
for _, testCase := range []validationTestCase{
{"Empty URL", &TestForm{URL: ""}, nil},
{"URL without port", &TestForm{URL: "http://test.lan/"}, nil},
{"URL with port", &TestForm{URL: "http://test.lan:3000/"}, nil},
{"URL with IPv6 address without port", &TestForm{URL: "http://[::1]/"}, nil},
{"URL with IPv6 address with port", &TestForm{URL: "http://[::1]:3000/"}, nil},
{"Invalid URL", &TestForm{URL: "http//test.lan/"}, expectedErrors},
{"Invalid schema", &TestForm{URL: "ftp://test.lan/"}, expectedErrors},
{"Invalid port", &TestForm{URL: "http://test.lan:3x4/"}, expectedErrors},
{"Invalid port with IPv6 address", &TestForm{URL: "http://[::1]:3x4/"}, expectedErrors},
} {
t.Run(testCase.description, func(t *testing.T) {
performValidationTest(t, testCase)
})