(t *testing.T)
| 471 | } |
| 472 | |
| 473 | func (s) TestClientSupportedCompressors(t *testing.T) { |
| 474 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 475 | defer cancel() |
| 476 | |
| 477 | for _, tt := range []struct { |
| 478 | desc string |
| 479 | ctx context.Context |
| 480 | want []string |
| 481 | }{ |
| 482 | { |
| 483 | desc: "No additional grpc-accept-encoding header", |
| 484 | ctx: ctx, |
| 485 | want: []string{"gzip"}, |
| 486 | }, |
| 487 | { |
| 488 | desc: "With additional grpc-accept-encoding header", |
| 489 | ctx: metadata.AppendToOutgoingContext(ctx, |
| 490 | "grpc-accept-encoding", "test-compressor-1", |
| 491 | "grpc-accept-encoding", "test-compressor-2", |
| 492 | ), |
| 493 | want: []string{"gzip", "test-compressor-1", "test-compressor-2"}, |
| 494 | }, |
| 495 | { |
| 496 | desc: "With additional empty grpc-accept-encoding header", |
| 497 | ctx: metadata.AppendToOutgoingContext(ctx, |
| 498 | "grpc-accept-encoding", "", |
| 499 | ), |
| 500 | want: []string{"gzip"}, |
| 501 | }, |
| 502 | { |
| 503 | desc: "With additional grpc-accept-encoding header with spaces between values", |
| 504 | ctx: metadata.AppendToOutgoingContext(ctx, |
| 505 | "grpc-accept-encoding", "identity, deflate", |
| 506 | ), |
| 507 | want: []string{"gzip", "identity", "deflate"}, |
| 508 | }, |
| 509 | } { |
| 510 | t.Run(tt.desc, func(t *testing.T) { |
| 511 | ss := &stubserver.StubServer{ |
| 512 | EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) { |
| 513 | got, err := grpc.ClientSupportedCompressors(ctx) |
| 514 | if err != nil { |
| 515 | return nil, err |
| 516 | } |
| 517 | |
| 518 | if !reflect.DeepEqual(got, tt.want) { |
| 519 | t.Errorf("unexpected client compressors got: %v, want: %v", got, tt.want) |
| 520 | } |
| 521 | |
| 522 | return &testpb.Empty{}, nil |
| 523 | }, |
| 524 | } |
| 525 | if err := ss.Start(nil); err != nil { |
| 526 | t.Fatalf("Error starting endpoint server: %v, want: nil", err) |
| 527 | } |
| 528 | defer ss.Stop() |
| 529 | |
| 530 | _, err := ss.Client.EmptyCall(tt.ctx, &testpb.Empty{}) |
nothing calls this directly
no test coverage detected