Skip to content

Instantly share code, notes, and snippets.

@arildojr7
Created August 10, 2023 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arildojr7/1e2df530999d11d3b795f22329dde00d to your computer and use it in GitHub Desktop.
Save arildojr7/1e2df530999d11d3b795f22329dde00d to your computer and use it in GitHub Desktop.
@IrisMockInterceptor
class MyInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain) = irisMockScope(chain) {
onGet(contains = "user/profile") mockResponse userProfileJson
onPost(endsWith = "/login") then {
delay(2_000) // simulating a slow response
if (requestContains("validPassword")) mockResponse(successLoginJson)
else mockResponse(errorPasswordJson)
}
enableLogs() // you can also log the calls
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment