Closed L7R7 closed 2 years ago
Yeah would love this.
Currently I just turn the servant app into a wai app and then use sydtest-wai
:
https://github.com/NorfairKing/smos/blob/release/smos-server-gen/src/Smos/Server/TestUtils.hs
I did this as well in another project because servant-client doesn't support ccookie-based auth. What I like about sydtest-wai is that I don't have to bother with the details of building the request.
I will see what I can come up with, expect a PR in a couple of days
Closing this as I'm happy for now. Thanks for helping me contribute!
I'd like to write tests for a servant-backed webservice where the API requires a context. A simple example is an API with basic auth, like described in the cookbook: https://docs.servant.dev/en/stable/cookbook/basic-auth/BasicAuth.html
I think that could be solved by adding
servantSpec
andservantSpecWithSetupFunc
variants for APIs that take a context and under the hood useserveWithContext
. What do you think? I'm happy to give it a try in a PR if that's something you'd like to have in the library.