Skip to content

Commit 92bbe61

Browse files
committed
test(common): format test code using runBlocking properly
Adjust indentation and formatting in DefaultHttpRequesterTest to improve readability while using runBlocking. Also, tidy up client initialization in DefaultMessagesApiTest.
1 parent 988b28e commit 92bbe61

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class DefaultMessagesApiTest : KoinTest {
4242
val chatsApi =
4343
DefaultMessagesApi(
4444
requester =
45-
DefaultHttpRequester(
46-
httpClient = mockHttpClient("invalid json response")
47-
)
45+
DefaultHttpRequester(httpClient = mockHttpClient("invalid json response"))
4846
)
4947

5048
val request = CreateMessageRequest.streamRequest(listOf(Message.user(("hello"))))

common/src/jvmTest/kotlin/com/tddworks/common/network/api/ktor/DefaultHttpRequesterTest.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,19 @@ class DefaultHttpRequesterTest : AutoCloseKoinTest() {
202202
}
203203

204204
@Test
205-
fun `should not return chat stream completion response when it's empty response`() = runBlocking {
206-
httpClient = mockHttpClient("")
207-
208-
val requester = DefaultHttpRequester(httpClient)
209-
210-
requester
211-
.streamRequest<StreamResponse> { url(path = "/v1/chat/completions") }
212-
.test {
213-
expectNoEvents()
214-
cancel()
215-
}
216-
}
205+
fun `should not return chat stream completion response when it's empty response`() =
206+
runBlocking {
207+
httpClient = mockHttpClient("")
208+
209+
val requester = DefaultHttpRequester(httpClient)
210+
211+
requester
212+
.streamRequest<StreamResponse> { url(path = "/v1/chat/completions") }
213+
.test {
214+
expectNoEvents()
215+
cancel()
216+
}
217+
}
217218

218219
@Test
219220
fun `should return chat stream completion response`() = runTest {

0 commit comments

Comments
 (0)