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 org.junit.Assert.assertEquals
10import org.junit.runner.RunWith
12@RunWith(AndroidJUnit4::class)
15 private val context = ApplicationProvider.getApplicationContext<android.content.Context>()
18 fun setGetRemoveRoundTrip() {
19 val scope = CoroutineScope(SupervisorJob() + Dispatchers.Unconfined)
20 val store = DraftStore(context, scope)
22 // Use a unique session ID so it doesn't collide with other tests.
23 val sid = "test-${System.nanoTime()}"
25 store.set(sid, "hello world")
26 assertEquals("hello world", store.get(sid))
29 store.set(sid, "updated")
30 assertEquals("updated", store.get(sid))
32 // Blank clears the entry
34 assertEquals("", store.get(sid))
37 store.set(sid, "text")
39 assertEquals("", store.get(sid))
45 fun getReturnsEmptyForUnknownSession() {
46 val store = DraftStore(context, CoroutineScope(SupervisorJob()))
47 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