Persistance: Note can now be put in the trash
This commit is contained in:
@@ -224,9 +224,6 @@ internal class NoteRepositoryImplTest {
|
||||
val note = createNote(user1.id, "1", listOf("a", "b"))
|
||||
assertThat(noteRepo.delete(user1.id, note.uuid))
|
||||
.isTrue
|
||||
|
||||
assertThat(noteRepo.delete(user1.id, note.uuid))
|
||||
.isFalse
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -289,4 +286,42 @@ internal class NoteRepositoryImplTest {
|
||||
.isEqualToComparingOnlyGivenFields(newNote2, "meta", "markdown", "html")
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
inner class Trash {
|
||||
|
||||
@Test
|
||||
fun `trashed noted should be restored`() {
|
||||
val note1 = createNote(user1.id, "1", listOf("a", "b"))
|
||||
|
||||
assertThat(noteRepo.delete(user1.id, note1.uuid, permanent = false))
|
||||
.isTrue
|
||||
|
||||
val isDeleted = db.notes
|
||||
.find { it.uuid eq note1.uuid }
|
||||
?.deleted
|
||||
|
||||
assertThat(isDeleted).`as`("Check that Notes.deleted is true").isTrue
|
||||
|
||||
assertThat(noteRepo.restore(user1.id, note1.uuid)).isTrue
|
||||
|
||||
val isDeleted2 = db.notes
|
||||
.find { it.uuid eq note1.uuid }
|
||||
?.deleted
|
||||
|
||||
assertThat(isDeleted2).`as`("Check that Notes.deleted is false after restore()").isFalse
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `permanent delete`() {
|
||||
val note1 = createNote(user1.id, "1", listOf("a", "b"))
|
||||
assertThat(noteRepo.delete(user1.id, note1.uuid, permanent = true))
|
||||
.isTrue
|
||||
|
||||
assertThat(noteRepo.restore(user1.id, note1.uuid)).isFalse
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user