Can you mock queries? I'm trying to test a HttpInt...
# apollo-kotlin
j
Can you mock queries? I'm trying to test a HttpInterceptor in my library via the MockServer and as I'm making a library I don't have any queries I could use.
b
To test your
HttpInterceptor
without any queries, you could pass it to a
HttpNetworkTransport
Oh no wait that doesn't help, you still need the generated operations
you could generate the code for a query one-time, and copy that to your test code
j
tried that, I have to copy like 1000 lines of code 😕
b
for 1 query? I got 370 lines here in my example
j
Still, I think thats just faster:
Copy code
interceptor.intercept(HttpRequest.Builder(HttpMethod.Get, "").build(), object : HttpInterceptorChain {

    override suspend fun proceed(request: HttpRequest): HttpResponse {
        assertEquals("Bearer ${supabaseClient.resolveAccessToken()}", request.headers.get("Authorization"))
        return HttpResponse.Builder(200).build()
    }

})
b
LGTM 👍