MCPcopy
hub / github.com/connectrpc/connect-go / TestClientStreamIterator

Function TestClientStreamIterator

handler_stream_test.go:25–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestClientStreamIterator(t *testing.T) {
26 t.Parallel()
27 // The server's view of a client streaming RPC is an iterator. For safety,
28 // and to match grpc-go's behavior, we should allocate a new message for each
29 // iteration.
30 stream := &ClientStream[pingv1.PingRequest]{
31 conn: &nopStreamingHandlerConn{},
32 }
33 assert.True(t, stream.Receive())
34 first := fmt.Sprintf("%p", stream.Msg())
35 assert.True(t, stream.Receive())
36 second := fmt.Sprintf("%p", stream.Msg())
37 assert.NotEqual(t, first, second, assert.Sprintf("should allocate a new message for each iteration"))
38}
39
40type nopStreamingHandlerConn struct {
41 StreamingHandlerConn

Callers

nothing calls this directly

Calls 5

TrueFunction · 0.92
NotEqualFunction · 0.92
SprintfFunction · 0.92
ReceiveMethod · 0.65
MsgMethod · 0.45

Tested by

no test coverage detected