MCPcopy Index your code
hub / github.com/dnote/dnote / TestGetNotes_FTSSearch_ShortWord

Function TestGetNotes_FTSSearch_ShortWord

pkg/server/app/notes_test.go:448–478  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

446}
447
448func 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(&note1), "preparing note1")
458
459 note2 := database.Note{UserID: user.ID, Deleted: false, Body: "d", BookUUID: b1.UUID}
460 testutils.MustExec(t, db.Save(&note2), "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
480func TestGetNotes_All(t *testing.T) {
481 db := testutils.InitMemoryDB(t)

Callers

nothing calls this directly

Calls 7

InitMemoryDBFunction · 0.92
SetupUserDataFunction · 0.92
MustExecFunction · 0.92
NewMockFunction · 0.92
EqualFunction · 0.92
NewTestFunction · 0.85
GetNotesMethod · 0.80

Tested by

no test coverage detected