aboutsummaryrefslogtreecommitdiffstats
path: root/modules/validation/validurl_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/validation/validurl_test.go')
-rw-r--r--modules/validation/validurl_test.go158
1 files changed, 79 insertions, 79 deletions
diff --git a/modules/validation/validurl_test.go b/modules/validation/validurl_test.go
index 39f7fa5d65..ce4898b271 100644
--- a/modules/validation/validurl_test.go
+++ b/modules/validation/validurl_test.go
@@ -9,98 +9,98 @@ import (
"gitea.com/go-chi/binding"
)
-var urlValidationTestCases = []validationTestCase{
- {
- description: "Empty URL",
- data: TestForm{
- URL: "",
- },
- expectedErrors: binding.Errors{},
- },
- {
- description: "URL without port",
- data: TestForm{
- URL: "http://test.lan/",
- },
- expectedErrors: binding.Errors{},
- },
- {
- description: "URL with port",
- data: TestForm{
- URL: "http://test.lan:3000/",
- },
- expectedErrors: binding.Errors{},
- },
- {
- description: "URL with IPv6 address without port",
- data: TestForm{
- URL: "http://[::1]/",
- },
- expectedErrors: binding.Errors{},
- },
- {
- description: "URL with IPv6 address with port",
- data: TestForm{
- URL: "http://[::1]:3000/",
+func Test_ValidURLValidation(t *testing.T) {
+ AddBindingRules()
+
+ urlValidationTestCases := []validationTestCase{
+ {
+ description: "Empty URL",
+ data: TestForm{
+ URL: "",
+ },
+ expectedErrors: binding.Errors{},
},
- expectedErrors: binding.Errors{},
- },
- {
- description: "Invalid URL",
- data: TestForm{
- URL: "http//test.lan/",
+ {
+ description: "URL without port",
+ data: TestForm{
+ URL: "http://test.lan/",
+ },
+ expectedErrors: binding.Errors{},
},
- expectedErrors: binding.Errors{
- binding.Error{
- FieldNames: []string{"URL"},
- Classification: binding.ERR_URL,
- Message: "Url",
+ {
+ description: "URL with port",
+ data: TestForm{
+ URL: "http://test.lan:3000/",
},
+ expectedErrors: binding.Errors{},
},
- },
- {
- description: "Invalid schema",
- data: TestForm{
- URL: "ftp://test.lan/",
+ {
+ description: "URL with IPv6 address without port",
+ data: TestForm{
+ URL: "http://[::1]/",
+ },
+ expectedErrors: binding.Errors{},
},
- expectedErrors: binding.Errors{
- binding.Error{
- FieldNames: []string{"URL"},
- Classification: binding.ERR_URL,
- Message: "Url",
+ {
+ description: "URL with IPv6 address with port",
+ data: TestForm{
+ URL: "http://[::1]:3000/",
},
+ expectedErrors: binding.Errors{},
},
- },
- {
- description: "Invalid port",
- data: TestForm{
- URL: "http://test.lan:3x4/",
+ {
+ description: "Invalid URL",
+ data: TestForm{
+ URL: "http//test.lan/",
+ },
+ expectedErrors: binding.Errors{
+ binding.Error{
+ FieldNames: []string{"URL"},
+ Classification: binding.ERR_URL,
+ Message: "Url",
+ },
+ },
},
- expectedErrors: binding.Errors{
- binding.Error{
- FieldNames: []string{"URL"},
- Classification: binding.ERR_URL,
- Message: "Url",
+ {
+ description: "Invalid schema",
+ data: TestForm{
+ URL: "ftp://test.lan/",
+ },
+ expectedErrors: binding.Errors{
+ binding.Error{
+ FieldNames: []string{"URL"},
+ Classification: binding.ERR_URL,
+ Message: "Url",
+ },
},
},
- },
- {
- description: "Invalid port with IPv6 address",
- data: TestForm{
- URL: "http://[::1]:3x4/",
+ {
+ description: "Invalid port",
+ data: TestForm{
+ URL: "http://test.lan:3x4/",
+ },
+ expectedErrors: binding.Errors{
+ binding.Error{
+ FieldNames: []string{"URL"},
+ Classification: binding.ERR_URL,
+ Message: "Url",
+ },
+ },
},
- expectedErrors: binding.Errors{
- binding.Error{
- FieldNames: []string{"URL"},
- Classification: binding.ERR_URL,
- Message: "Url",
+ {
+ description: "Invalid port with IPv6 address",
+ data: TestForm{
+ URL: "http://[::1]:3x4/",
+ },
+ expectedErrors: binding.Errors{
+ binding.Error{
+ FieldNames: []string{"URL"},
+ Classification: binding.ERR_URL,
+ Message: "Url",
+ },
},
},
- },
-}
-
-func Test_ValidURLValidation(t *testing.T) {
- AddBindingRules()
+ }
for _, testCase := range urlValidationTestCases {
t.Run(testCase.description, func(t *testing.T) {