| 23 | ) |
| 24 | |
| 25 | func 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 | |
| 40 | type nopStreamingHandlerConn struct { |
| 41 | StreamingHandlerConn |