zio-http icon indicating copy to clipboard operation
zio-http copied to clipboard

Improve developer experience when used with ZIO Test

Open calvinlfer opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. In 3.0.0-RC3, methods like updateStatus(...)/withStatus(...)/withHeaders(...) were changed to just status(...)/headers(...) which causes problems when writing tests resulting in code like this:

for 
  ...
  response  <- app.runZIO(Request.get(URL(Root / "plaintext")))
  responseStatus = response.status
yield assertTrue(responseStatus == Status.Ok)

If you inline responseStatus into the assert like so: assertTrue(response.status == Status.Ok) You get a macro expansion error in Scala 3.3.1 on Temurin JDK 11 image as it appears to formulate that response.status is partially applied as it thinks you are using response.status(...)

Describe the solution you'd like Earlier we could write assertTrue(response.status == Status.Ok) without running into this which could be confusing for others running into this issue as the code appears valid. It would be great to continue to be able to support it as it were.

calvinlfer avatar Nov 02 '23 10:11 calvinlfer

Thanks @calvinlfer this is actually a good hint. We have already an issue in zio core for this https://github.com/zio/zio/issues/8518 I think the problem is the zio macro. It is probably selecting the method in the wrong way. I'll leave this issue open for tracking, but fixing should happen in zio core

987Nabil avatar Nov 02 '23 21:11 987Nabil