Open qustavo opened 8 months ago
Depends what test you are looking for. For my case, I used testcontainers to spin-up containers and test Dapr functionalities during the integration testing phase. It's particularly useful when a service provider doesn't offer a way to test their proprietary service locally. With Dapr it's just a matter of swapping a container with an open-source alternative.
You can find an example in the following repository: https://github.com/etiennetremel/testcontainers-dapr-example
I'm following a similar approach but without docker, just by running the binnary (os.Exec
). Using docker sounds interesting, portable and contained, specially when it comes to finding unused ports. Although it would be nice to have some package implementing a testing server.
Have you experimented creating a grpc server for test?
I haven't played with GRPC for tests, but I wouldn't expect much difference from a standard HTTP server
have you started a HTTP server for tests?
The examples in this repo are validated using mechanical markdown - https://github.com/dapr/mechanical-markdown Have a look at the validation github workflow along with the README files which validates the output against expected.
I'm opening this issue to ask how should I test components that are using dapr. In my case, I needed to make sure that my code was using pubsub correctly. I ended up
exec.Command("dapr", "run", ... more args ...)
and creating aClient
and aService
that conneted to the dapr daemon. While this worked, I wonder if there is a programmatic way to do this. I skim through this repo anddapr/dapr
and I could find anything. Is this the right way to test? is there a better one?Thanks!