diff --git a/pkg/models/project_test.go b/pkg/models/project_test.go index d1e975b3a..0c30bdb6e 100644 --- a/pkg/models/project_test.go +++ b/pkg/models/project_test.go @@ -533,9 +533,9 @@ func TestProject_ReadAll(t *testing.T) { ls := projects3.([]*Project) if db.ParadeDBAvailable() { - // ParadeDB fuzzy prefix matching returns more results - // (e.g. "TEST10" also matches "test1", "test11", etc.) - require.NotEmpty(t, ls) + // ParadeDB fuzzy(1, prefix=true) on "TEST10" also matches + // "test1", "test11", "test19", "test30" (edit distance 1), etc. + require.Len(t, ls, 6) projectIDs := make([]int64, len(ls)) for i, p := range ls { projectIDs[i] = p.ID diff --git a/pkg/models/task_collection_test.go b/pkg/models/task_collection_test.go index 4dcf28f81..a455b2065 100644 --- a/pkg/models/task_collection_test.go +++ b/pkg/models/task_collection_test.go @@ -1783,8 +1783,8 @@ func TestTaskCollection_ReadAll(t *testing.T) { } if db.ParadeDBAvailable() { - // ParadeDB fuzzy prefix matching returns more results than ILIKE, - // so we only check that expected tasks are contained in results. + // ParadeDB fuzzy(1, prefix=true) on "17" also matches tokens within + // edit distance 1 ("1", "7", "10"-"19", "27", "47"), returning more results. t.Run("search for task index", func(t *testing.T) { db.LoadAndAssertFixtures(t) s := db.NewSession() @@ -1794,6 +1794,7 @@ func TestTaskCollection_ReadAll(t *testing.T) { got, _, _, err := lt.ReadAll(s, &user.User{ID: 1}, "number #17", 0, 50) require.NoError(t, err) gotTasks := got.([]*Task) + require.Len(t, gotTasks, 14) gotIDs := make([]int64, len(gotTasks)) for i, tsk := range gotTasks { gotIDs[i] = tsk.ID diff --git a/pkg/webtests/project_test.go b/pkg/webtests/project_test.go index f6bafdf35..0c87f211e 100644 --- a/pkg/webtests/project_test.go +++ b/pkg/webtests/project_test.go @@ -17,6 +17,7 @@ package webtests import ( + "encoding/json" "net/url" "testing" @@ -51,9 +52,16 @@ func TestProject(t *testing.T) { rec, err := testHandler.testReadAllWithUser(url.Values{"s": []string{"Test1"}}, nil) require.NoError(t, err) assert.Contains(t, rec.Body.String(), `Test1`) - if !db.ParadeDBAvailable() { - // ParadeDB fuzzy(1, prefix=true) matches Test2, Test3, etc. - // (edit distance 1 from "Test1"), so only check exclusions without ParadeDB. + + var projects []models.Project + require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &projects)) + + if db.ParadeDBAvailable() { + // ParadeDB fuzzy(1, prefix=true) on "Test1" also matches + // Test2-Test9 (edit distance 1), Test10+ (prefix), etc. + require.Len(t, projects, 12) + } else { + require.Len(t, projects, 2) assert.NotContains(t, rec.Body.String(), `Test2`) assert.NotContains(t, rec.Body.String(), `Test3`) assert.NotContains(t, rec.Body.String(), `Test4`)