fix: 目录搜索转义 LIKE 通配符并拒绝编号 inline
This commit is contained in:
@@ -131,6 +131,35 @@ func TestF03PresenceAndDirectory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDirectoryLikeEscapesUnderscore(t *testing.T) {
|
||||
t.Parallel()
|
||||
app, db, _ := openPresence(t)
|
||||
ctx := context.Background()
|
||||
insertEP(t, db, "e_ab1", "underscore")
|
||||
insertEP(t, db, "exab2", "wildcard")
|
||||
insertEP(t, db, "pct", "has%percent")
|
||||
|
||||
q, _, err := app.Directory(ctx, &protocol.DirectoryList{
|
||||
V: protocol.Version, Type: protocol.TypeDirectoryList, RID: "u1", Query: "e_ab", Limit: 10,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(q) != 1 || q[0].ID != "e_ab1" {
|
||||
t.Fatalf("want only e_ab1, got %+v", q)
|
||||
}
|
||||
|
||||
q, _, err = app.Directory(ctx, &protocol.DirectoryList{
|
||||
V: protocol.Version, Type: protocol.TypeDirectoryList, RID: "u2", Query: "%", Limit: 10,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(q) != 1 || q[0].ID != "pct" {
|
||||
t.Fatalf("literal %% should not match all, got %+v", q)
|
||||
}
|
||||
}
|
||||
|
||||
func TestF04PresenceWatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
app, db, down := openPresence(t)
|
||||
|
||||
Reference in New Issue
Block a user