You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
823 B
28 lines
823 B
package console
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBuildUserFeedbackWhere(t *testing.T) {
|
|
where, args := buildUserFeedbackWhere(&userFeedbackListReq{})
|
|
if where != "1=1" || len(args) != 0 {
|
|
t.Fatalf("empty: where %q args %v", where, args)
|
|
}
|
|
|
|
where, args = buildUserFeedbackWhere(&userFeedbackListReq{
|
|
User: "138", Content: "耳机", Start: 10, End: 20,
|
|
})
|
|
for _, sub := range []string{"f.uid = ?", "u.phone LIKE ?", "f.message LIKE ?", "f.createtime >= ?", "f.createtime < ?"} {
|
|
if !strings.Contains(where, sub) {
|
|
t.Fatalf("where %q missing %q", where, sub)
|
|
}
|
|
}
|
|
if len(args) != 8 {
|
|
t.Fatalf("args len = %d, want 8: %v", len(args), args)
|
|
}
|
|
if args[0] != "138" || args[1] != "%138%" || args[5] != "%耳机%" || args[6] != int64(10) || args[7] != int64(20) {
|
|
t.Fatalf("args = %v", args)
|
|
}
|
|
}
|
|
|