mirror of
https://github.com/openflocon/Flocon.git
synced 2026-04-30 06:09:32 +00:00
feat: [NETWORK] mocks can throw errors (#133)
* feat: [NETWORK] mocks can throw errors * added into android * added on ktor --------- Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
parent
a50169189e
commit
3cb5abd33f
20 changed files with 640 additions and 339 deletions
|
|
@ -19,13 +19,24 @@ fun toRemote(mock: MockNetworkDomainModel): MockNetworkResponseDataModel = MockN
|
|||
urlPattern = mock.expectation.urlPattern,
|
||||
method = mock.expectation.method,
|
||||
),
|
||||
response = MockNetworkResponseDataModel.Response(
|
||||
httpCode = mock.response.httpCode,
|
||||
body = mock.response.body,
|
||||
mediaType = mock.response.mediaType,
|
||||
delay = mock.response.delay,
|
||||
headers = mock.response.headers,
|
||||
),
|
||||
response = when(val r = mock.response) {
|
||||
is MockNetworkDomainModel.Response.Body -> MockNetworkResponseDataModel.Response(
|
||||
httpCode = r.httpCode,
|
||||
body = r.body,
|
||||
mediaType = r.mediaType,
|
||||
delay = r.delay,
|
||||
headers = r.headers,
|
||||
errorException = null
|
||||
)
|
||||
is MockNetworkDomainModel.Response.Exception -> MockNetworkResponseDataModel.Response(
|
||||
httpCode = null,
|
||||
body = null,
|
||||
mediaType = null,
|
||||
delay = r.delay,
|
||||
headers = null,
|
||||
errorException = r.classPath
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalUuidApi::class)
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ data class MockNetworkResponseDataModel(
|
|||
|
||||
@Serializable
|
||||
data class Response(
|
||||
val httpCode: Int,
|
||||
val body: String,
|
||||
val mediaType: String,
|
||||
val delay: Long,
|
||||
val headers: Map<String, String>,
|
||||
val httpCode: Int?,
|
||||
val body: String?,
|
||||
val mediaType: String?,
|
||||
val delay: Long?,
|
||||
val headers: Map<String, String>?,
|
||||
val errorException: String?,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue