I’m trying to test my ZServerEndpoints, preferably using ZIO Test. I have not found examples of this, so I’m trying to use the example on tapir’s website. However, the example uses SttpBackendStub.asynchronousFuture, which I don’t think is what I need for ZIO.
The docs say to check sttp’s docs, and there it says to use HttpClientZioBackend.stub and add "com.softwaremill.sttp.client3" %% "zio" % "3.8.7" as a dependency, but the examples on tapir’s GitHub use a different dependency, "com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % Versions.sttp, so I’m very confused
There’s a couple of ZIO-compatible backends (they use different low-level http client implementations). If you’re using HttpClientZioBackend in your app, you should use HttpClientZioBackend.stub to create the stub. This comes from the "com.softwaremill.sttp.client3" %% "zio" dependency. Other backends are included in other dependencies.
Can you send a link to the page and section in the docs you found misleading? Maybe there’s something to fix
What I ended up using (and I don’t know why I forgot about it in the first place) is the example test that comes with “Adopt tapir”, which only requires "com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server", just had to change the Any in RIOMonadError[Any] to the needed environment for every test and it worked like a charm.
Which, in hindsight, is correct, I don’t actually need neither the ZIO dependency from sttp nor the ones from the GitHub examples, just the above dependency.
Since “Adopt tapir” comes with an example test given the effect type and server library, I think it’d be helpful to mention, maybe in addition to reading the sttp docs, that such an example exists in “Adopt tapir”.