refactor(db): add Users.Update (#7263)

This commit is contained in:
Joe Chen
2022-11-27 15:19:44 +08:00
committed by GitHub
parent a7dbc970df
commit 13099a7e4f
16 changed files with 423 additions and 109 deletions

View File

@@ -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)
})
}
}