-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
305 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
app/src/main/java/org/ageage/eggplant/common/api/BookmarkService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
package org.ageage.eggplant.common.api | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.ageage.eggplant.common.api.response.BookmarkEntryResponse | ||
import org.ageage.eggplant.common.api.response.BookmarkStarResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface BookmarkService { | ||
@GET("/entry/jsonlite/") | ||
fun bookmarkEntry(@Query("url") url: String): Flow<BookmarkEntryResponse> | ||
suspend fun bookmarkEntry(@Query("url") url: String): BookmarkEntryResponse | ||
|
||
@GET("/entry.json") | ||
fun startCount(@Query("uri") url: String): Flow<BookmarkStarResponse> | ||
suspend fun startCount(@Query("uri") url: String): BookmarkStarResponse | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/test/java/org/ageage/eggplant/common/TestCoroutineRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.ageage.eggplant.common | ||
|
||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.test.* | ||
import org.junit.rules.TestWatcher | ||
import org.junit.runner.Description | ||
|
||
class TestCoroutineRule : TestWatcher() { | ||
|
||
private val testCoroutineDispatcher = TestCoroutineDispatcher() | ||
|
||
override fun starting(description: Description?) { | ||
super.starting(description) | ||
Dispatchers.setMain(testCoroutineDispatcher) | ||
} | ||
|
||
override fun finished(description: Description?) { | ||
super.finished(description) | ||
Dispatchers.resetMain() | ||
testCoroutineDispatcher.cleanupTestCoroutines() | ||
} | ||
|
||
fun runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) { | ||
testCoroutineDispatcher.runBlockingTest { block() } | ||
} | ||
} |
Oops, something went wrong.