| 84 | } |
| 85 | |
| 86 | func TestServerStreamForClient(t *testing.T) { |
| 87 | t.Parallel() |
| 88 | stream := &ServerStreamForClient[pingv1.PingResponse]{ |
| 89 | conn: &nopStreamingClientConn{}, |
| 90 | } |
| 91 | // Ensure that each call to Receive allocates a new message. This helps |
| 92 | // vtprotobuf, which doesn't automatically zero messages before unmarshaling |
| 93 | // (see https://connectrpc.com/connect/issues/345), and it's also |
| 94 | // less error-prone for users. |
| 95 | assert.True(t, stream.Receive()) |
| 96 | first := fmt.Sprintf("%p", stream.Msg()) |
| 97 | assert.True(t, stream.Receive()) |
| 98 | second := fmt.Sprintf("%p", stream.Msg()) |
| 99 | assert.NotEqual(t, first, second) |
| 100 | conn, err := stream.Conn() |
| 101 | assert.Nil(t, err) |
| 102 | assert.NotNil(t, conn) |
| 103 | } |
| 104 | |
| 105 | func TestBidiStreamForClient_InitErrNoPanics(t *testing.T) { |
| 106 | t.Parallel() |