mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 22:17:03 +05:30
refactor: improve read posts search performance
This commit is contained in:
parent
89b821ebf1
commit
cbd7f2fca4
6 changed files with 31 additions and 44 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -23,8 +23,8 @@ class ReadPostsQueriesTest {
|
|||
fun `mark post as read`() {
|
||||
val id = UUID.randomUUID().toString()
|
||||
postQueries.markRead(id)
|
||||
assertThat(postQueries.isRead(id).executeAsOne()).isNotNull()
|
||||
assertThat(postQueries.selectAllPosts().executeAsList()).contains(id)
|
||||
postQueries.markUnread(id)
|
||||
assertThat(postQueries.isRead(id).executeAsOneOrNull()).isNull()
|
||||
assertThat(postQueries.selectAllPosts().executeAsList()).doesNotContain(id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -32,7 +32,7 @@ class SavedPostQueriesTest {
|
|||
@Test
|
||||
fun `update post in database`() {
|
||||
// Get 1 post
|
||||
val post = createTestData(1)[0]
|
||||
val post = createTestData(1).first()
|
||||
|
||||
// Insert post into DB
|
||||
postQueries.insertOrReplacePost(post)
|
||||
|
@ -46,15 +46,14 @@ class SavedPostQueriesTest {
|
|||
assertThat(postsCount).isEqualTo(1)
|
||||
|
||||
// Check if post is updated
|
||||
val postFromDb = postQueries.selectPost(post.shortId).executeAsOne()
|
||||
|
||||
val postFromDb = postQueries.selectAllPosts().executeAsOne()
|
||||
assertThat(postFromDb.submitterName).isEqualTo("Fake name")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `get post from db`() {
|
||||
// Get 1 post
|
||||
val post = createTestData(1)[0]
|
||||
val post = createTestData(1).first()
|
||||
|
||||
// Insert post into DB
|
||||
postQueries.insertOrReplacePost(post)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue