Andrew O Hart
02/24/2022, 5:42 PM@Test
fun testDownloadCompletedSuccessfully() {
runBlocking {
launch(Dispatchers.Main) {
val result = retriever.fetchData()
assertEquals(RemoteResultType.SUCCESS, result.type)
}
}
}
which does this:
override suspend fun fetchData(): RemoteDataResult {
val responseContent: String
return try {
responseContent = httpClient.get { url(hostURL + serviceURL) }.body()
RemoteDataResult(responseContent, RemoteResultType.SUCCESS)
} catch (e: ClientRequestException) {
return RemoteDataResult(e.message, RemoteResultType.CLIENT_ERROR)
} catch (e: ServerResponseException) {
return RemoteDataResult(e.message, RemoteResultType.SERVER_ERROR)
} catch (e: Exception) {
return RemoteDataResult(e.message, RemoteResultType.GENERAL_ERROR)
}
}
But it always returns as GENERAL_ERROR.
I tried debugging and it says this:
Exception in http request: Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “run.mocky.io” which could put your confidential information at risk."
We do have some test endpoints on mocky to simulate stuff like 500 errors etc.
How can I work around this?nhaarman
07/20/2022, 10:47 AM