Request not finished if body not read
LodewijkSioen opened this issue · 1 comments
I'm using an xUnit collection fixture to setup Alba. In my test I have the following (pseudo) code:
using(ISession and Transaction)
{
Put Something in the database;
}
await System.Scenario(s => {
s.Put.UpdateSomething.ToUrl("/api/");
s.StatusCodeShouldBe(200);
});
using(ISession and transaction)
{
Assert if Something has been updated
}
My assertion fails at this point. If I check what's in the database after the test has run, I see the updated values. I can make the test run if I read the body of the request before my assertion.
My guess is that the body of my request is only streamed if I actually read it. That means that the transaction (from middleware) around my api-call is still open when I do my assertions.
Is there an easy way to tell Alba to close the request when I'm not interested in the body?
Nevermind, I just realised that this is an issue with my code 😄 Some client can also just listen to the statuscode and not bother with the body. They'll get a 200 but the transaction can still fail. I'll have to put my transactions elsewhere.