Skip to content

Commit e1c42a3

Browse files
committed
test(anthropic-client): replace runBlocking with runTest in test
Use runTest instead of runBlocking in DefaultMessagesApiTest for better coroutine test support.
1 parent 43916b8 commit e1c42a3

File tree

1 file changed

+2
-3
lines changed
  • anthropic-client/anthropic-client-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/internal

1 file changed

+2
-3
lines changed

anthropic-client/anthropic-client-core/src/jvmTest/kotlin/com/tddworks/anthropic/api/messages/api/internal/DefaultMessagesApiTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import app.cash.turbine.test
44
import com.tddworks.anthropic.api.messages.api.*
55
import com.tddworks.anthropic.api.mockHttpClient
66
import com.tddworks.common.network.api.ktor.internal.DefaultHttpRequester
7-
import kotlinx.coroutines.runBlocking
87
import kotlinx.coroutines.test.runTest
98
import kotlinx.serialization.json.Json
109
import org.junit.jupiter.api.Assertions.assertEquals
@@ -38,13 +37,13 @@ class DefaultMessagesApiTest : KoinTest {
3837
}
3938

4039
@Test
41-
fun `should return nothing stream data when not json response`() = runBlocking {
40+
fun `should return nothing stream data when not json response`() = runTest {
4241
// Given
4342
val chatsApi =
4443
DefaultMessagesApi(
4544
requester =
4645
DefaultHttpRequester(
47-
httpClient = mockHttpClient("{\"type\": \"message_stop\"}")
46+
httpClient = mockHttpClient("invalid json response")
4847
)
4948
)
5049

0 commit comments

Comments
 (0)