aboutsummaryrefslogtreecommitdiffstats
path: root/models/user_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/user_test.go')
-rw-r--r--models/user_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/models/user_test.go b/models/user_test.go
index ba700d3659..9d011f32a0 100644
--- a/models/user_test.go
+++ b/models/user_test.go
@@ -6,6 +6,7 @@ package models
import (
"math/rand"
+ "strings"
"testing"
"code.gitea.io/gitea/modules/setting"
@@ -181,3 +182,34 @@ func TestGetOrgRepositoryIDs(t *testing.T) {
// User 5's team has no access to any repo
assert.Len(t, accessibleRepos, 0)
}
+
+func TestNewGitSig(t *testing.T) {
+ users := make([]*User, 0, 20)
+ sess := x.NewSession()
+ defer sess.Close()
+ sess.Find(&users)
+
+ for _, user := range users {
+ sig := user.NewGitSig()
+ assert.NotContains(t, sig.Name, "<")
+ assert.NotContains(t, sig.Name, ">")
+ assert.NotContains(t, sig.Name, "\n")
+ assert.NotEqual(t, len(strings.TrimSpace(sig.Name)), 0)
+ }
+}
+
+func TestDisplayName(t *testing.T) {
+ users := make([]*User, 0, 20)
+ sess := x.NewSession()
+ defer sess.Close()
+ sess.Find(&users)
+
+ for _, user := range users {
+ displayName := user.DisplayName()
+ assert.Equal(t, strings.TrimSpace(displayName), displayName)
+ if len(strings.TrimSpace(user.FullName)) == 0 {
+ assert.Equal(t, user.Name, displayName)
+ }
+ assert.NotEqual(t, len(strings.TrimSpace(displayName)), 0)
+ }
+}