Closed grivera64 closed 2 months ago
There is no proper API for something like this. When I want to mock client disconnects, I always put a simple proxy in between. This way I can close the connection in that proxy, and simulate a real disconnect more accurately.
How do you mock a client disconnection in tests? I am trying to write a test for a handler that uses
ctx.SetBodyStreamWriter(sw)
to write a response to the client.Currently, I have tried
ctx.CloseBodyStream()
, but this seems to cause issues when reading the Response programmatically. My next thought was to usectx.Hijack(...)
, but from my understanding, Hijack overrides default functionality over interrupting an existing running connection.Thanks in advance for the help!