(t *testing.T)
| 478 | } |
| 479 | |
| 480 | func 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(¬e1), "preparing note1") |
| 489 | |
| 490 | note2 := database.Note{UserID: user.ID, Deleted: false, Body: "d", BookUUID: b1.UUID} |
| 491 | testutils.MustExec(t, db.Save(¬e2), "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 | } |
nothing calls this directly
no test coverage detected