mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-26 06:16:56 +09:00
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:
1 parent
ce7364e215
commit
8abda62312
388 files changed
+18410
-29561
No files matched your search
@@ -23,16 +23,8 @@ func TestRegisterForm_IsDomainAllowed_Empty(t *testing.T) {
|
||||
func TestRegisterForm_IsDomainAllowed_InvalidEmail(t *testing.T) {
|
||||
defer test.MockVariableValue(&setting.Service.EmailDomainAllowList, []glob.Glob{glob.MustCompile("gitea.io")})()
|
||||
|
||||
tt := []struct {
|
||||
email string
|
||||
}{
|
||||
{"invalid-email"},
|
||||
{"gitea.io"},
|
||||
}
|
||||
|
||||
for _, v := range tt {
|
||||
form := RegisterForm{Email: v.email}
|
||||
|
||||
for _, email := range []string{"invalid-email", "gitea.io"} {
|
||||
form := RegisterForm{Email: email}
|
||||
assert.False(t, form.IsEmailDomainAllowed())
|
||||
}
|
||||
}
|
||||
@@ -87,23 +79,12 @@ func TestRegisterForm_IsDomainAllowed_BlockedEmail(t *testing.T) {
|
||||
func TestDetectInvalidOAuth2ApplicationRedirectURI(t *testing.T) {
|
||||
defer test.MockVariableValue(&setting.OAuth2.CustomSchemes)()
|
||||
setting.OAuth2.CustomSchemes = []string{"my-app"}
|
||||
assertValid := func(t *testing.T, s string, valid bool) {
|
||||
ret := DetectInvalidOAuth2ApplicationRedirectURI([]string{s})
|
||||
if valid {
|
||||
assert.Empty(t, ret)
|
||||
} else {
|
||||
assert.Equal(t, s, ret)
|
||||
}
|
||||
for _, uri := range []string{"my-app:", "my-app:/foo", "http://foo", "https://foo"} {
|
||||
assert.Empty(t, DetectInvalidOAuth2ApplicationRedirectURI([]string{uri}))
|
||||
}
|
||||
for _, uri := range []string{"my-app", "ftp:", "ftp://foo", "https://[invalid"} {
|
||||
assert.Equal(t, uri, DetectInvalidOAuth2ApplicationRedirectURI([]string{uri}))
|
||||
}
|
||||
assertValid(t, "my-app:", true)
|
||||
assertValid(t, "my-app:/foo", true)
|
||||
assertValid(t, "http://foo", true)
|
||||
assertValid(t, "https://foo", true)
|
||||
|
||||
assertValid(t, "my-app", false)
|
||||
assertValid(t, "ftp:", false)
|
||||
assertValid(t, "ftp://foo", false)
|
||||
assertValid(t, "https://[invalid", false)
|
||||
|
||||
ret := DetectInvalidOAuth2ApplicationRedirectURI([]string{"my-app:", "http://foo", "https://foo"})
|
||||
assert.Empty(t, ret)
|
||||
|
||||
Reference in new issue
Block a user