Skip to content

Commit

Permalink
fixup! fixup! KTOR-5410 Fix server ContentConverter not triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l committed Jan 16, 2023
1 parent d285b06 commit 5aebe43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ public fun TestApplicationRequest.setBody(value: ByteReadPacket) {
/**
* Sets a multipart HTTP request body.
*/
public fun buildMultipart(boundary: String, parts: List<PartData>): ByteReadChannel = writer(Dispatchers.IOBridge) {
@OptIn(DelicateCoroutinesApi::class)
public fun buildMultipart(
boundary: String,
parts: List<PartData>
): ByteReadChannel = GlobalScope.writer(Dispatchers.IOBridge) {
if (parts.isEmpty()) return@writer

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import kotlin.test.*
class TestApplicationEngineTest {
@Test
fun testCustomDispatcher() {
@OptIn(
ExperimentalCoroutinesApi::class,
InternalCoroutinesApi::class
)
@OptIn(InternalCoroutinesApi::class)
fun CoroutineDispatcher.withDelay(delay: Delay): CoroutineDispatcher =
object : CoroutineDispatcher(), Delay by delay {
override fun isDispatchNeeded(context: CoroutineContext): Boolean =
Expand Down Expand Up @@ -277,7 +274,7 @@ class TestApplicationEngineTest {
HttpHeaders.ContentType,
ContentType.MultiPart.FormData.withParameter("boundary", boundary).toString()
)
setBody(boundary, multipart)
bodyChannel = buildMultipart(boundary, multipart)
}
assertEquals(HttpStatusCode.OK, response.response.status())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TestEngineMultipartTest {
},
setup = {
addHeader(HttpHeaders.ContentType, contentType.toString())
setBody(
bodyChannel = buildMultipart(
boundary,
listOf(
PartData.FileItem(
Expand Down Expand Up @@ -142,7 +142,7 @@ class TestEngineMultipartTest {
},
setup = {
addHeader(HttpHeaders.ContentType, contentType.toString())
setBody(
bodyChannel = buildMultipart(
boundary,
listOf(
PartData.FileItem(
Expand Down

0 comments on commit 5aebe43

Please sign in to comment.