(t *testing.T, e env)
| 228 | } |
| 229 | |
| 230 | func testIdentityEncoding(t *testing.T, e env) { |
| 231 | te := newTest(t, e) |
| 232 | te.startServer(&testServer{security: e.security}) |
| 233 | defer te.tearDown() |
| 234 | tc := testgrpc.NewTestServiceClient(te.clientConn()) |
| 235 | |
| 236 | // Unary call |
| 237 | payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, 5) |
| 238 | if err != nil { |
| 239 | t.Fatal(err) |
| 240 | } |
| 241 | req := &testpb.SimpleRequest{ |
| 242 | ResponseType: testpb.PayloadType_COMPRESSABLE, |
| 243 | ResponseSize: 10, |
| 244 | Payload: payload, |
| 245 | } |
| 246 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 247 | defer cancel() |
| 248 | ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs("something", "something")) |
| 249 | if _, err := tc.UnaryCall(ctx, req); err != nil { |
| 250 | t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, <nil>", err) |
| 251 | } |
| 252 | // Streaming RPC |
| 253 | stream, err := tc.FullDuplexCall(ctx, grpc.UseCompressor("identity")) |
| 254 | if err != nil { |
| 255 | t.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err) |
| 256 | } |
| 257 | payload, err = newPayload(testpb.PayloadType_COMPRESSABLE, int32(31415)) |
| 258 | if err != nil { |
| 259 | t.Fatal(err) |
| 260 | } |
| 261 | sreq := &testpb.StreamingOutputCallRequest{ |
| 262 | ResponseType: testpb.PayloadType_COMPRESSABLE, |
| 263 | ResponseParameters: []*testpb.ResponseParameters{{Size: 10}}, |
| 264 | Payload: payload, |
| 265 | } |
| 266 | if err := stream.Send(sreq); err != nil { |
| 267 | t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, sreq, err) |
| 268 | } |
| 269 | stream.CloseSend() |
| 270 | if _, err := stream.Recv(); err != nil { |
| 271 | t.Fatalf("%v.Recv() = %v, want <nil>", stream, err) |
| 272 | } |
| 273 | if _, err := stream.Recv(); err != io.EOF { |
| 274 | t.Fatalf("%v.Recv() = %v, want io.EOF", stream, err) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // renameCompressor is a grpc.Compressor wrapper that allows customizing the |
| 279 | // Type() of another compressor. |
no test coverage detected