(t *testing.T)
| 536 | } |
| 537 | |
| 538 | func (s) TestAcceptCompressorsCallOption(t *testing.T) { |
| 539 | tests := []struct { |
| 540 | name string |
| 541 | callOption grpc.CallOption |
| 542 | wantHeader string |
| 543 | }{ |
| 544 | { |
| 545 | name: "with AcceptCompressors", |
| 546 | callOption: experimental.AcceptCompressors("gzip"), |
| 547 | wantHeader: "gzip", |
| 548 | }, |
| 549 | { |
| 550 | name: "without AcceptCompressors uses default", |
| 551 | callOption: nil, |
| 552 | wantHeader: grpcutil.RegisteredCompressors(), |
| 553 | }, |
| 554 | } |
| 555 | |
| 556 | for _, tt := range tests { |
| 557 | t.Run(tt.name, func(t *testing.T) { |
| 558 | ss := &stubserver.StubServer{ |
| 559 | EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) { |
| 560 | md, _ := metadata.FromIncomingContext(ctx) |
| 561 | header := md.Get("grpc-accept-encoding") |
| 562 | |
| 563 | if len(header) != 1 || header[0] != tt.wantHeader { |
| 564 | t.Errorf("unexpected grpc-accept-encoding header: got %v, want %v", header, tt.wantHeader) |
| 565 | } |
| 566 | return &testpb.Empty{}, nil |
| 567 | }, |
| 568 | } |
| 569 | if err := ss.Start(nil); err != nil { |
| 570 | t.Fatalf("failed to start server: %v", err) |
| 571 | } |
| 572 | defer ss.Stop() |
| 573 | |
| 574 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 575 | defer cancel() |
| 576 | |
| 577 | opts := []grpc.CallOption{} |
| 578 | if tt.callOption != nil { |
| 579 | opts = append(opts, tt.callOption) |
| 580 | } |
| 581 | |
| 582 | if _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}, opts...); err != nil { |
| 583 | t.Fatalf("EmptyCall failed: %v", err) |
| 584 | } |
| 585 | }) |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | func (s) TestCompressorRegister(t *testing.T) { |
| 590 | for _, e := range listTestEnv() { |
nothing calls this directly
no test coverage detected