How do I use MockEngine (<https://ktor.io/clients/...
# ktor
e
How do I use MockEngine (https://ktor.io/clients/http-client/testing.html)? I can see how I can set it up, but I have a class with a private
HttpClient
d
Your class has to accept an engine via it's ctor or something.
e
I started doing something like that, but with whole config, problem was that I must remember to make my tests have same install as my service, and
client.config { install  { ... }}
didn't seem to work. But passing the engine doesn't have that problem so it might be a good idea, giving it a try
I'm unable to pass in engine, tried
engine: HttpClientEngine
, but then it won't accept
Apache
because of type mismatch
d
You can pass
Apache.create {}
e
Nice, then I can do
engine : HttpClientEngine = Apache.create()
in ctor, and to create
MockEngine
I can do
MockEngine.create { addHandler { ... } }
and pass that in ctor. Thanks!