why
02/08/2021, 10:34 AMClientRequestException
in my unit tests? is it possible?
I’m using the MockEngine like this
val httpClientMock = HttpClient(MockEngine) {
HttpResponseValidator { }
install(JsonFeature) {
serializer = GsonSerializer()
}
engine {
addHandler { request ->
val page = request.url.parameters["page"]!!.toInt()
when {
page < 38 -> {
val t = ContentType.Application.Json.toString()
val headers = headersOf("Content-Type" to listOf(t))
TextContent(reposJson, ContentType.Application.Json)
respond(reposJson, headers = headers)
}
else -> throw "I can't ctor the exception"
}
}
}
}
rsetkus
02/08/2021, 6:49 PMrespondError(HttpStatusCode.BadRequest, reposJson, headers)
. Change status code to whatever you need based on your use case.why
02/09/2021, 10:44 AM