swift-server/async-http-client

support fake I/O layer

Opened this issue · 1 comments

Many libraries depend on AHC which is great. The downside is that that means to test these libraries they either need to provide a layer which allows to fake AHC or we have to spin up an actual server (say on localhost) to write integration tests with these libraries. That's super tedious and sometimes impossible.

AHC should allow to take a fake I/O layer which allows to run any AHC request without ever doing a network connection or a DNS lookup.

In the #392 suggestion, that would live in Tier 1. So for testing, one could create a fake HTTPService which never actually speaks HTTP over a network protocol.

Chatting about this with @fabianfett, this should probably be a feature for the middle ware feature (#393). So if the middle wares are good enough, it should be possible to do anything that can happen with a request without ever having to create a network connection (Channel). If that's possible, then we don't need a real fake I/O layer.

One question that would arise is that it'd be useful to switch to a fake AHC in Tier 1 (to share it with other libraries) but in #393 I suggested that the middlewares live at Tier 2. Maybe we should accept middlewares in both Tier 1 & 2?