mirror of
https://github.com/gogs/gogs.git
synced 2025-12-22 08:09:59 +01:00
refactor(db): add Users.Update (#7263)
This commit is contained in:
@@ -95,3 +95,43 @@ func TestEllipsis(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
str string
|
||||
limit int
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "empty string with zero limit",
|
||||
str: "",
|
||||
limit: 0,
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "smaller length than limit",
|
||||
str: "ab",
|
||||
limit: 3,
|
||||
want: "ab",
|
||||
},
|
||||
{
|
||||
name: "same length as limit",
|
||||
str: "abc",
|
||||
limit: 3,
|
||||
want: "abc",
|
||||
},
|
||||
{
|
||||
name: "greater length than limit",
|
||||
str: "ab",
|
||||
limit: 1,
|
||||
want: "a",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got := Truncate(test.str, test.limit)
|
||||
assert.Equal(t, test.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user