How to unit test streaming RPCs #675
Unanswered
jonnylangefeld
asked this question in
Q&A
Replies: 1 comment
-
Hey @jonnylangefeld , currently these constructors for the Stream types aren't exported. See the docs for the stream types: e.g. https://pkg.go.dev/connectrpc.com/connect#BidiStream
To test handlers the current recommended way is to use the net/http/httptest package and create a server with a corresponding client to invoke the server. See the tests in the connect package as examples: Line 446 in 297532d |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a unit test file for every
service
. In the unit test I instantiate the server likeAnd then just call the functions directly. Check below for a working example
unfold for working unit test
But now for a different service I have an rpc with a stream:
(
s.updates
is a channel)How can I test this?
This is my attempt, but it's not quite right yet:
Beta Was this translation helpful? Give feedback.
All reactions