https://kotlinlang.org logo
#ktor
Title
# ktor
a

andylamax

02/05/2021, 7:13 AM
Hello, the code below for Ktor MockEngine for 1.5.1
Copy code
val client = HttpClient(MockEngine) {
            engine {
                addHandler { request ->
                    val body = request.body
                    val req = body.toByteArray().decodeToString()
                    println(req)
                    respond("Testing", headers = responseHeaders)
                }
           }
}

val res = client.get<String>("/")
expect(res).toBe("test")
throws
Copy code
io.ktor.utils.io.ByteChannelCtorKt.ByteReadChannel([B)Lio/ktor/utils/io/ByteReadChannel;
java.lang.NoSuchMethodError: io.ktor.utils.io.ByteChannelCtorKt.ByteReadChannel([B)Lio/ktor/utils/io/ByteReadChannel;
	at io.ktor.client.engine.mock.MockUtilsKt.respond(MockUtils.kt:74)
	at io.ktor.client.engine.mock.MockUtilsKt.respond$default(MockUtils.kt:72)
	at CreateEndpointTest$should_have_a_valid_path$1$client$1$1$1.invokeSuspend(CreateEndpointTest.kt:35)
	at CreateEndpointTest$should_have_a_valid_path$1$client$1$1$1.invoke(CreateEndpointTest.kt)
	at CreateEndpointTest$should_have_a_valid_path$1$client$1$1$1.invoke(CreateEndpointTest.kt)
	at io.ktor.client.engine.mock.MockEngine.execute(MockEngine.kt:61)
When executed on JVM And throws
Copy code
e: java.lang.IllegalStateException: Deserializer for declaration public <http://io.ktor.utils.io/ByteReadChannel%7C8179199761482737139[0]|io.ktor.utils.io/ByteReadChannel|8179199761482737139[0]> is not found
        at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.handleNoModuleDeserializerFound(KotlinIrLinker.kt:471)
        at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.findModuleDeserializer(KotlinIrLinker.kt:359)
        at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.deserializeIrSymbolData(KotlinIrLinker.kt:388)
        at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.deserializeIrSymbol(KotlinIrLinker.kt:404)
        at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeIrSymbolAndRemap(IrFileDeserializer.kt:144)
        at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeCall(IrFileDeserializer.kt:387)
        at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeOperation(IrFileDeserializer.kt:897)
        at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeExpression(IrFileDeserializer.kt:938)
        at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeMemberAccessCommon(IrFileDeserializer.kt:345)
        at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeCall(IrFileDeserializer.kt:404)
When executed on jsBrowser Am I missing a dependency?
Never mind. I had a rogue dependency that was pulling ktor 1.4.2 in
4 Views