Skip to content

Commit 135b222

Browse files
committed
Cover RealPostBookkeepingWriter
Signed-off-by: Matt Ramotar <[email protected]>
1 parent c0be786 commit 135b222

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

xplat/lib/repositories/post/impl/src/commonTest/kotlin/org/mobilenativefoundation/trails/xplat/lib/repositories/post/impl/store/bookkeeper/PostBookkeepingRemoverTest.kt renamed to xplat/lib/repositories/post/impl/src/commonTest/kotlin/org/mobilenativefoundation/trails/xplat/lib/repositories/post/impl/store/bookkeeper/RealPostBookkeepingRemoverTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.mobilenativefoundation.trails.xplat.lib.models.post.Post
99
import org.mobilenativefoundation.trails.xplat.lib.repositories.post.impl.store.db.PostBookkeepingDAO
1010
import kotlin.test.Test
1111

12-
class PostBookkeepingRemoverTest {
12+
class RealPostBookkeepingRemoverTest {
1313
private val bookkeepingDAO = mock<PostBookkeepingDAO>(MockMode.autoUnit)
1414
private val bookkeepingRemover = RealPostBookkeepingRemover(bookkeepingDAO)
1515

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.mobilenativefoundation.trails.xplat.lib.repositories.post.impl.store.bookkeeper
2+
3+
import dev.mokkery.MockMode
4+
import dev.mokkery.mock
5+
import dev.mokkery.verify
6+
import dev.mokkery.verifyNoMoreCalls
7+
import org.mobilenativefoundation.trails.xplat.lib.models.post.Post
8+
import org.mobilenativefoundation.trails.xplat.lib.repositories.post.impl.store.db.PostBookkeepingDAO
9+
import kotlin.test.Test
10+
11+
class RealPostBookkeepingWriterTest {
12+
13+
private val bookkeepingDAO = mock<PostBookkeepingDAO>(MockMode.autoUnit)
14+
private val bookkeepingWriter = RealPostBookkeepingWriter(bookkeepingDAO)
15+
16+
@Test
17+
fun recordFailedDelete_givenNormalDAO_whenCalled_thenShouldInsert() {
18+
// Given
19+
val key = Post.Key(1)
20+
val timestamp = 1L
21+
22+
// When
23+
bookkeepingWriter.recordFailedDelete(key, timestamp)
24+
25+
// Then
26+
verify { bookkeepingDAO.insertFailedDelete(key.id, timestamp) }
27+
verifyNoMoreCalls(bookkeepingDAO)
28+
}
29+
30+
@Test
31+
fun recordFailedUpdate_givenNormalDAO_whenCalled_thenShouldUpdate() {
32+
// Given
33+
val key = Post.Key(1)
34+
val timestamp = 1L
35+
36+
// When
37+
bookkeepingWriter.recordFailedUpdate(key, timestamp)
38+
39+
// Then
40+
verify { bookkeepingDAO.insertFailedUpdate(key.id, timestamp) }
41+
verifyNoMoreCalls(bookkeepingDAO)
42+
}
43+
44+
@Test
45+
fun recordFailedDeletes_givenNormalDAO_whenCalledWithMultipleKeys_thenShouldInsertAll() {
46+
// Given
47+
val key1 = Post.Key(1)
48+
val key2 = Post.Key(2)
49+
val key3 = Post.Key(3)
50+
val timestamp = 1L
51+
52+
// When
53+
bookkeepingWriter.recordFailedDeletes(listOf(key1, key2, key3), timestamp)
54+
55+
// Then
56+
verify { bookkeepingDAO.insertFailedDelete(key1.id, timestamp) }
57+
verify { bookkeepingDAO.insertFailedDelete(key2.id, timestamp) }
58+
verify { bookkeepingDAO.insertFailedDelete(key3.id, timestamp) }
59+
verifyNoMoreCalls(bookkeepingDAO)
60+
}
61+
}

0 commit comments

Comments
 (0)