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

Function TestGetNotes_All

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

Source from the content-addressed store, hash-verified

478}
479
480func TestGetNotes_All(t *testing.T) {
481 db := testutils.InitMemoryDB(t)
482
483 user := testutils.SetupUserData(db, "user@test.com", "password123")
484 b1 := database.Book{UserID: user.ID, Label: "testBook"}
485 testutils.MustExec(t, db.Save(&b1), "preparing book")
486
487 note1 := database.Note{UserID: user.ID, Deleted: false, Body: "a b c", BookUUID: b1.UUID}
488 testutils.MustExec(t, db.Save(&note1), "preparing note1")
489
490 note2 := database.Note{UserID: user.ID, Deleted: false, Body: "d", BookUUID: b1.UUID}
491 testutils.MustExec(t, db.Save(&note2), "preparing note2")
492
493 a := NewTest()
494 a.DB = db
495 a.Clock = clock.NewMock()
496
497 result, err := a.GetNotes(user.ID, GetNotesParams{
498 Search: "",
499 Page: 1,
500 PerPage: 30,
501 })
502 if err != nil {
503 t.Fatal(errors.Wrap(err, "getting notes with FTS search for 'a'"))
504 }
505
506 assert.Equal(t, result.Total, int64(2), "Should not find all notes")
507 assert.Equal(t, len(result.Notes), 2, "Should not find all notes")
508
509 for _, note := range result.Notes {
510 assert.Equal(t, strings.Contains(note.Body, "<dnotehl>"), false, "There should be no keywords")
511 assert.Equal(t, strings.Contains(note.Body, "</dnotehl>"), false, "There should be no keywords")
512 }
513 assert.Equal(t, result.Notes[0].Body, "d", "Full content should be returned")
514 assert.Equal(t, result.Notes[1].Body, "a b c", "Full content should be returned")
515}

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