1package soy.iko.opencode.data.repo
3import androidx.test.core.app.ApplicationProvider
4import androidx.test.ext.junit.runners.AndroidJUnit4
5import kotlinx.coroutines.CoroutineScope
6import kotlinx.coroutines.Dispatchers
7import kotlinx.coroutines.SupervisorJob
8import kotlinx.coroutines.cancel
9import kotlinx.coroutines.runBlocking
10import org.junit.Assert.assertEquals
12import org.junit.runner.RunWith
14@RunWith(AndroidJUnit4::class)
17 private val context = ApplicationProvider.getApplicationContext<android.content.Context>()
20 fun setGetRemoveRoundTrip() = runBlocking {
21 val scope = CoroutineScope(SupervisorJob() + Dispatchers.Unconfined)
22 val store = DraftStore(context, scope)
24 // Use a unique session ID so it doesn't collide with other tests.
25 val sid = "test-${System.nanoTime()}"
27 store.set(sid, "hello world")
28 assertEquals("hello world", store.get(sid))
31 store.set(sid, "updated")
32 assertEquals("updated", store.get(sid))
34 // Blank clears the entry
36 assertEquals("", store.get(sid))
39 store.set(sid, "text")
41 assertEquals("", store.get(sid))
47 fun getReturnsEmptyForUnknownSession() {
48 val store = DraftStore(context, CoroutineScope(SupervisorJob()))
49 assertEquals("", store.get("never-set-${System.nanoTime()}"))
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