(t *testing.T)
| 446 | } |
| 447 | |
| 448 | func TestGetNotes_FTSSearch_ShortWord(t *testing.T) { |
| 449 | db := testutils.InitMemoryDB(t) |
| 450 | |
| 451 | user := testutils.SetupUserData(db, "user@test.com", "password123") |
| 452 | b1 := database.Book{UserID: user.ID, Label: "testBook"} |
| 453 | testutils.MustExec(t, db.Save(&b1), "preparing book") |
| 454 | |
| 455 | // Create notes with short words |
| 456 | note1 := database.Note{UserID: user.ID, Deleted: false, Body: "a b c", BookUUID: b1.UUID} |
| 457 | testutils.MustExec(t, db.Save(¬e1), "preparing note1") |
| 458 | |
| 459 | note2 := database.Note{UserID: user.ID, Deleted: false, Body: "d", BookUUID: b1.UUID} |
| 460 | testutils.MustExec(t, db.Save(¬e2), "preparing note2") |
| 461 | |
| 462 | a := NewTest() |
| 463 | a.DB = db |
| 464 | a.Clock = clock.NewMock() |
| 465 | |
| 466 | result, err := a.GetNotes(user.ID, GetNotesParams{ |
| 467 | Search: "a", |
| 468 | Page: 1, |
| 469 | PerPage: 30, |
| 470 | }) |
| 471 | if err != nil { |
| 472 | t.Fatal(errors.Wrap(err, "getting notes with FTS search for 'a'")) |
| 473 | } |
| 474 | |
| 475 | assert.Equal(t, result.Total, int64(1), "Should find 1 note") |
| 476 | assert.Equal(t, len(result.Notes), 1, "Should return 1 note") |
| 477 | assert.Equal(t, strings.Contains(result.Notes[0].Body, "<dnotehl>a</dnotehl>"), true, "Should contain highlighted 'a'") |
| 478 | } |
| 479 | |
| 480 | func TestGetNotes_All(t *testing.T) { |
| 481 | db := testutils.InitMemoryDB(t) |
nothing calls this directly
no test coverage detected