Skip to content

Commit f0e8658

Browse files
committed
fix test
1 parent f9601ec commit f0e8658

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

services/context/context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ func Contexter() func(next http.Handler) http.Handler {
215215
func (ctx *Context) HasError() bool {
216216
hasErr, _ := ctx.Data["HasError"].(bool)
217217
hasErr = hasErr || ctx.Flash.ErrorMsg != ""
218+
if !hasErr {
219+
return false
220+
}
218221
if ctx.Flash.ErrorMsg == "" {
219222
ctx.Flash.ErrorMsg = ctx.GetErrMsg()
220223
}

services/forms/user_form_test.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
package forms
55

66
import (
7-
"strconv"
87
"testing"
98

10-
auth_model "code.gitea.io/gitea/models/auth"
119
"code.gitea.io/gitea/modules/setting"
1210

1311
"github.com/gobwas/glob"
@@ -104,28 +102,3 @@ func TestRegisterForm_IsDomainAllowed_BlockedEmail(t *testing.T) {
104102
assert.Equal(t, v.valid, form.IsEmailDomainAllowed())
105103
}
106104
}
107-
108-
func TestNewAccessTokenForm_GetScope(t *testing.T) {
109-
tests := []struct {
110-
form NewAccessTokenForm
111-
scope auth_model.AccessTokenScope
112-
expectedErr error
113-
}{
114-
{
115-
form: NewAccessTokenForm{Name: "test", Scope: []string{"read:repository"}},
116-
scope: "read:repository",
117-
},
118-
{
119-
form: NewAccessTokenForm{Name: "test", Scope: []string{"read:repository", "write:user"}},
120-
scope: "read:repository,write:user",
121-
},
122-
}
123-
124-
for i, test := range tests {
125-
t.Run(strconv.Itoa(i), func(t *testing.T) {
126-
scope, err := test.form.GetScope()
127-
assert.Equal(t, test.expectedErr, err)
128-
assert.Equal(t, test.scope, scope)
129-
})
130-
}
131-
}

0 commit comments

Comments
 (0)