1package soy.iko.opencode.data.repo
3import kotlinx.coroutines.runBlocking
4import org.junit.Assert.assertEquals
9 /** The protected no-arg constructor runs with no Context, so disk ops are skipped and the
10 * in-memory queue can be exercised directly. */
11 private class TestOutbox : OutboxStore()
13 private fun msg(id: String, sessionId: String, text: String, createdAt: Long) =
14 OutboxMessage(id = id, profileId = "p", sessionId = sessionId, text = text, createdAt = createdAt)
17 fun enqueueOrdersByCreatedAtAndDedupesById() = runBlocking {
18 val store = TestOutbox()
19 store.enqueue(msg("b", "s1", "B", createdAt = 2))
20 store.enqueue(msg("a", "s1", "A", createdAt = 1))
21 // Same id replaces the prior entry rather than adding a duplicate.
22 store.enqueue(msg("a", "s1", "A2", createdAt = 1))
23 assertEquals(listOf("a", "b"), store.messages.value.map { it.id })
24 assertEquals("A2", store.messages.value.first { it.id == "a" }.text)
28 fun removeForSessionDropsOnlyThatSession() = runBlocking {
29 val store = TestOutbox()
30 store.enqueue(msg("1", "s1", "x", createdAt = 1))
31 store.enqueue(msg("2", "s2", "y", createdAt = 2))
32 store.removeForSession("s1")
33 assertEquals(listOf("2"), store.messages.value.map { it.id })
37 fun removeDropsSingleMessage() = runBlocking {
38 val store = TestOutbox()
39 store.enqueue(msg("1", "s1", "x", createdAt = 1))
40 store.enqueue(msg("2", "s1", "y", createdAt = 2))
42 assertEquals(listOf("2"), store.messages.value.map { it.id })
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list